nextcloud/core/lostpassword/index.php

33 lines
1.3 KiB
PHP
Raw Normal View History

2011-09-26 01:33:22 +04:00
<?php
/**
* Copyright (c) 2010 Frank Karlitschek karlitschek@kde.org
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
$RUNTIME_NOAPPS = TRUE; //no apps
2011-10-03 22:41:52 +04:00
require_once('../../lib/base.php');
2011-09-26 01:33:22 +04:00
// Someone lost their password:
if (isset($_POST['user'])) {
if (OC_User::userExists($_POST['user'])) {
$token = sha1($_POST['user']+uniqId());
OC_Preferences::setValue($_POST['user'], 'owncloud', 'lostpassword', $token);
$email = OC_Preferences::getValue($_POST['user'], 'lostpassword', 'email', '');
if (!empty($email)) {
2011-10-03 22:41:52 +04:00
$link = OC_Helper::linkTo('core/lostpassword', 'resetpassword.php', null, true).'?user='.$_POST['user'].'&token='.$token;
$tmpl = new OC_Template('core/lostpassword', 'email');
$tmpl->assign('link', $link);
$msg = $tmpl->fetchPage();
$l = new OC_L10N('core');
mail($email, $l->t('Owncloud password reset'), $msg);
}
2011-10-03 22:41:52 +04:00
OC_Template::printGuestPage('core/lostpassword', 'lostpassword', array('error' => false, 'requested' => true));
2011-09-26 01:33:22 +04:00
} else {
2011-10-03 22:41:52 +04:00
OC_Template::printGuestPage('core/lostpassword', 'lostpassword', array('error' => true, 'requested' => false));
2011-09-26 01:33:22 +04:00
}
} else {
2011-10-03 22:41:52 +04:00
OC_Template::printGuestPage('core/lostpassword', 'lostpassword', array('error' => false, 'requested' => false));
2011-09-26 01:33:22 +04:00
}