aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorBart Visscher <bartv@thisnet.nl>2011-10-03 20:41:52 +0200
committerBart Visscher <bartv@thisnet.nl>2011-10-03 20:44:01 +0200
commite8c6252a4ce1151b11f1faa8e602c06aae4294d8 (patch)
tree28975fd3648fd245a0cec9d7d5d3c9c838108202 /core
parentdec810666538a94c1af69c4a54cd8ed5cc067579 (diff)
downloadnextcloud-server-e8c6252a4ce1151b11f1faa8e602c06aae4294d8.tar.gz
nextcloud-server-e8c6252a4ce1151b11f1faa8e602c06aae4294d8.zip
Move lostpassword to core dir
Diffstat (limited to 'core')
-rw-r--r--core/lostpassword/index.php32
-rw-r--r--core/lostpassword/resetpassword.php27
-rw-r--r--core/lostpassword/templates/email.php1
-rw-r--r--core/lostpassword/templates/lostpassword.php17
-rw-r--r--core/lostpassword/templates/resetpassword.php14
-rw-r--r--core/templates/login.php2
6 files changed, 92 insertions, 1 deletions
diff --git a/core/lostpassword/index.php b/core/lostpassword/index.php
new file mode 100644
index 00000000000..de0d393ec78
--- /dev/null
+++ b/core/lostpassword/index.php
@@ -0,0 +1,32 @@
+<?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
+require_once('../../lib/base.php');
+
+// 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)) {
+ $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);
+ }
+ OC_Template::printGuestPage('core/lostpassword', 'lostpassword', array('error' => false, 'requested' => true));
+ } else {
+ OC_Template::printGuestPage('core/lostpassword', 'lostpassword', array('error' => true, 'requested' => false));
+ }
+} else {
+ OC_Template::printGuestPage('core/lostpassword', 'lostpassword', array('error' => false, 'requested' => false));
+}
diff --git a/core/lostpassword/resetpassword.php b/core/lostpassword/resetpassword.php
new file mode 100644
index 00000000000..1c78d720947
--- /dev/null
+++ b/core/lostpassword/resetpassword.php
@@ -0,0 +1,27 @@
+<?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
+require_once('../../lib/base.php');
+
+// Someone wants to reset their password:
+if(isset($_GET['token']) && isset($_GET['user']) && OC_Preferences::getValue($_GET['user'], 'owncloud', 'lostpassword') === $_GET['token']) {
+ if (isset($_POST['password'])) {
+ if (OC_User::setPassword($_GET['user'], $_POST['password'])) {
+ OC_Preferences::deleteKey($_GET['user'], 'owncloud', 'lostpassword');
+ OC_Template::printGuestPage('core/lostpassword', 'resetpassword', array('success' => true));
+ } else {
+ OC_Template::printGuestPage('core/lostpassword', 'resetpassword', array('success' => false));
+ }
+ } else {
+ OC_Template::printGuestPage('core/lostpassword', 'resetpassword', array('success' => false));
+ }
+} else {
+ // Someone lost their password
+ OC_Template::printGuestPage('core/lostpassword', 'lostpassword', array('error' => false, 'requested' => false));
+}
diff --git a/core/lostpassword/templates/email.php b/core/lostpassword/templates/email.php
new file mode 100644
index 00000000000..d146d8e4c37
--- /dev/null
+++ b/core/lostpassword/templates/email.php
@@ -0,0 +1 @@
+<?php echo str_replace('{link}', $_['link'], $l->t('Use the following link to reset your password: {link}')) ?>
diff --git a/core/lostpassword/templates/lostpassword.php b/core/lostpassword/templates/lostpassword.php
new file mode 100644
index 00000000000..4b871963b80
--- /dev/null
+++ b/core/lostpassword/templates/lostpassword.php
@@ -0,0 +1,17 @@
+<form action="index.php" method="post">
+ <fieldset>
+ <?php echo $l->t('You will receive a link to reset your password via Email.'); ?>
+ <?php if ($_['requested']): ?>
+ <?php echo $l->t('Requested'); ?>
+ <?php else: ?>
+ <?php if ($_['error']): ?>
+ <?php echo $l->t('Login failed!'); ?>
+ <?php endif; ?>
+ <p class="infield">
+ <label for="user" class="infield"><?php echo $l->t( 'Username' ); ?></label>
+ <input type="text" name="user" id="user" value="" autocomplete="off" required autofocus />
+ </p>
+ <input type="submit" id="submit" value="<?php echo $l->t('Request reset'); ?>" />
+ <?php endif; ?>
+ </fieldset>
+</form>
diff --git a/core/lostpassword/templates/resetpassword.php b/core/lostpassword/templates/resetpassword.php
new file mode 100644
index 00000000000..56257de7f13
--- /dev/null
+++ b/core/lostpassword/templates/resetpassword.php
@@ -0,0 +1,14 @@
+<form action="<?php echo 'resetpassword.php?'.$_SERVER['QUERY_STRING']; ?>" method="post">
+ <fieldset>
+ <?php if($_['success']): ?>
+ <h1><?php echo $l->t('Your password was reset'); ?></h1>
+ <p><a href="<?php echo OC::$WEBROOT ?>/"><?php echo $l->t('To login page'); ?></a></p>
+ <?php else: ?>
+ <p class="infield">
+ <label for="password" class="infield"><?php echo $l->t( 'New password' ); ?></label>
+ <input type="password" name="password" id="password" value="" required />
+ </p>
+ <input type="submit" id="submit" value="<?php echo $l->t('Reset password'); ?>" />
+ <?php endif; ?>
+ </fieldset>
+</form>
diff --git a/core/templates/login.php b/core/templates/login.php
index 46b44c24d78..aff0afac203 100644
--- a/core/templates/login.php
+++ b/core/templates/login.php
@@ -1,7 +1,7 @@
<form action="index.php" method="post">
<fieldset>
<?php if($_['error']): ?>
- <a href="./lostpassword/"><?php echo $l->t('Lost your password?'); ?></a>
+ <a href="./core/lostpassword/"><?php echo $l->t('Lost your password?'); ?></a>
<?php endif; ?>
<p class="infield">
<label for="user" class="infield"><?php echo $l->t( 'Username' ); ?></label>