diff options
author | Lukas Fleischer <archlinux@cryptocrack.de> | 2013-03-19 13:10:12 +0100 |
---|---|---|
committer | Lukas Fleischer <archlinux@cryptocrack.de> | 2013-03-19 14:03:33 +0100 |
commit | 5d31bb24502536d53968f1ba0062d2b0aedb11c5 (patch) | |
tree | d30a2a0b49af116ac839000bd2cf354db62bfcca /web/lib/acctfuncs.inc.php | |
parent | a386bbd35d20465ae182b7aadf3fd2dfcbd5250f (diff) | |
download | aur-5d31bb24502536d53968f1ba0062d2b0aedb11c5.tar.gz aur-5d31bb24502536d53968f1ba0062d2b0aedb11c5.tar.xz |
Move reset key submission to a separate function
This allows for reusing reset key submission for other things, such as
sending an initial password reset code during account registration.
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
Diffstat (limited to 'web/lib/acctfuncs.inc.php')
-rw-r--r-- | web/lib/acctfuncs.inc.php | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/web/lib/acctfuncs.inc.php b/web/lib/acctfuncs.inc.php index 9c0998a5..edca8a30 100644 --- a/web/lib/acctfuncs.inc.php +++ b/web/lib/acctfuncs.inc.php @@ -582,6 +582,32 @@ function create_resetkey($resetkey, $uid) { } /** + * Send a reset key to a specific e-mail address + * + * @param string $email E-mail address of the user resetting their password + * @param string $body Body of the email + * + * @return void + */ +function send_resetkey($email, $body) { + global $AUR_LOCATION; + + $uid = uid_from_email($email); + if ($uid != NULL && $uid != 'None') { + # We (ab)use new_sid() to get a random 32 characters long string + $resetkey = new_sid(); + create_resetkey($resetkey, $uid); + # Send email with confirmation link + $body = wordwrap($body, 70); + $body .= "\n\n". + "{$AUR_LOCATION}/" . get_uri('/passreset/') . "?". + "resetkey={$resetkey}"; + $headers = "Reply-to: nobody@archlinux.org\nFrom:aur-notify@archlinux.org\nX-Mailer: PHP\nX-MimeOLE: Produced By AUR"; + @mail($email, 'AUR Password Reset', $body, $headers); + } +} + +/** * Change a user's password in the database if reset key and e-mail are correct * * @param string $hash New MD5 hash of a user's password |