if (OC_User::userExists($_POST['user'])) {
$token = sha1($_POST['user']+uniqId());
OC_Preferences::setValue($_POST['user'], 'owncloud', 'lostpassword', $token);
- // TODO send email with link+token
- $link = OC_Helper::linkTo('lostpassword', 'resetpassword.php', null, true).'?user='.$_POST['user'].'&token='.$token;
+ $email = OC_Preferences::getValue($_POST['user'], 'lostpassword', 'email', '');
+ if (!empty($email)) {
+ $link = OC_Helper::linkTo('lostpassword', 'resetpassword.php', null, true).'?user='.$_POST['user'].'&token='.$token;
+ $tmpl = new OC_Template('lostpassword', 'email');
+ $tmpl->assign('link', $link);
+ $msg = $tmpl->fetchPage();
+ $l = new OC_L10N('core');
+ mail($email, $l->t('Owncloud password reset'), $msg);
+ }
OC_Template::printGuestPage('lostpassword', 'lostpassword', array('error' => false, 'requested' => true));
} else {
OC_Template::printGuestPage('lostpassword', 'lostpassword', array('error' => true, 'requested' => false));