summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBart Visscher <bartv@thisnet.nl>2011-09-26 21:11:50 +0200
committerBart Visscher <bartv@thisnet.nl>2011-09-26 21:17:26 +0200
commit676838ac31d2fa98266736e59abfcbf6f30fb03b (patch)
treeab962348b8e80017c0d5b8cf168550c1931370ff
parentf14930389505eda61ec4cbcdf59a54e63513802b (diff)
downloadnextcloud-server-676838ac31d2fa98266736e59abfcbf6f30fb03b.tar.gz
nextcloud-server-676838ac31d2fa98266736e59abfcbf6f30fb03b.zip
Implement mailing of password reset link
-rw-r--r--lostpassword/index.php11
-rw-r--r--lostpassword/templates/email.php1
2 files changed, 10 insertions, 2 deletions
diff --git a/lostpassword/index.php b/lostpassword/index.php
index 0c078343a8d..6d629a71089 100644
--- a/lostpassword/index.php
+++ b/lostpassword/index.php
@@ -14,8 +14,15 @@ if (isset($_POST['user'])) {
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));
diff --git a/lostpassword/templates/email.php b/lostpassword/templates/email.php
new file mode 100644
index 00000000000..d146d8e4c37
--- /dev/null
+++ b/lostpassword/templates/email.php
@@ -0,0 +1 @@
+<?php echo str_replace('{link}', $_['link'], $l->t('Use the following link to reset your password: {link}')) ?>