From c5c397e1c33b8ee0a61e09f6af5f3d0107ed9370 Mon Sep 17 00:00:00 2001 From: Evangelos Foutras Date: Thu, 12 Nov 2009 17:21:59 +0200 Subject: [PATCH 2/2] Implement 'Password Reset' facility (FS#3061) This works by adding a new field to the 'Users' table called 'ResetKey', which is a 32 characters long, random string. When the user requests a password reset, a new 'reset key' is generated and sent to the user's e-mail address in the form of a link in the following format: http://aur.archlinux.org/passreset.php?resetkey= When the above link is followed, the user is presented with a form to verify his/her e-mail address and specify the new desired password. If the e-mail address matches the reset key in the database, the new password is assigned to the account. If there is an error, a relevant message is displayed and the user is prompted to re-enter the required information. Upon successful completion of this procedure, the ResetKey field in the database is blanked and the specific key cannot be reused. One SQL query is needed to add the ResetKey field to the 'Users' table: ALTER TABLE `Users` ADD `ResetKey` CHAR(32) NOT NULL DEFAULT ''; --- support/schema/aur-schema.sql | 2 +- web/html/passreset.php | 137 +++++++++++++++++++++++++++++++++++++++++ web/template/login_form.php | 2 +- 3 files changed, 139 insertions(+), 2 deletions(-) create mode 100644 web/html/passreset.php diff --git a/support/schema/aur-schema.sql b/support/schema/aur-schema.sql index 8d5c427..39da1bd 100644 --- a/support/schema/aur-schema.sql +++ b/support/schema/aur-schema.sql @@ -26,6 +26,7 @@ CREATE TABLE Users ( Username CHAR(32) NOT NULL, Email CHAR(64) NOT NULL, Passwd CHAR(32) NOT NULL, + ResetKey CHAR(32) NOT NULL DEFAULT '', RealName CHAR(64) NOT NULL DEFAULT '', LangPreference CHAR(2) NOT NULL DEFAULT 'en', IRCNick CHAR(32) NOT NULL DEFAULT '', @@ -229,4 +230,3 @@ CREATE TABLE IF NOT EXISTS TU_Votes ( VoteID int(10) unsigned NOT NULL, UserID int(10) unsigned NOT NULL ); - diff --git a/web/html/passreset.php b/web/html/passreset.php new file mode 100644 index 0000000..6fbd1ca --- /dev/null +++ b/web/html/passreset.php @@ -0,0 +1,137 @@ + + +
+
+ +
+
+ '.$error.'

'; + } + ?> + +
+ + + + + + + + + + + + + +
+
+ +
+ +

', + ''); ?>

+
+

+

+ +
+ +
+
+ +" /> +[Forgot Password] - -- 1.6.5.2