shaver%mozilla.org e451a2b2d7 Beating some things with the rustico stick. Huzzah.
git-svn-id: svn://10.0.0.236/trunk@214061 18797224-902f-48f8-a5cc-f745e15eee43
2006-10-24 09:59:24 +00:00

59 lines
1.4 KiB
PHP

<?php
/**
* Page to reset passwords for existing accounts
*
* @package amo
* @subpackage docs
*
*/
startProcessing('resetpassword.tpl', null, null, 'rustico');
require_once 'includes.php';
if (! (array_key_exists('email', $_GET) && array_key_exists('code', $_GET)) ) {
triggerError('There was an error processing your request.');
}
$user = user::getUserByEmail($_GET['email']);
if ($user === false) {
// bad email address
triggerError('There was an error processing your request.');
}
$authorized = $user->checkResetPasswordCode($_GET['email'], $_GET['code']);
if ($authorized === false) {
// bad code
triggerError('There was an error processing your request.');
}
$bad_input = false;
$success = false;
if (array_key_exists('password', $_POST)
&& array_key_exists('passwordconfirm', $_POST)
&& !empty($_POST['password'])) {
if ($_POST['password'] != $_POST['passwordconfirm']) {
$bad_input = true;
}
if ($bad_input === false) {
$user->setPassword($_POST['password']);
if ($user->UserMode == 'D' && !empty($user->ConfirmationCode)) {
$user->confirm($user->ConfirmationCode);
}
$success = true;
}
}
// Assign template variables.
$tpl->assign(
array( 'title' => 'Firefox Add-ons Password Recovery',
'currentTab' => null,
'bad_input' => $bad_input,
'success' => $success
)
);
?>