better handling of unconfirmed email addresses
darcs-hash:20080804133253-84dde-4b1ceb6feabaaad503f8777d6f21545b2bb87e85.gz
This commit is contained in:
parent
506843e55d
commit
f2203d1df6
@ -198,6 +198,8 @@ class RecoverpasswordAction extends Action {
|
|||||||
$user = User::staticGet('nickname', common_canonical_nickname($nore));
|
$user = User::staticGet('nickname', common_canonical_nickname($nore));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# See if it's an unconfirmed email address
|
||||||
|
|
||||||
if (!$user) {
|
if (!$user) {
|
||||||
$confirm_email = Confirm_address::staticGet('address', common_canonical_email($nore));
|
$confirm_email = Confirm_address::staticGet('address', common_canonical_email($nore));
|
||||||
if ($confirm_email && $confirm_email->address_type == 'email') {
|
if ($confirm_email && $confirm_email->address_type == 'email') {
|
||||||
@ -210,16 +212,28 @@ class RecoverpasswordAction extends Action {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Try to get an unconfirmed email address if they used a user name
|
||||||
|
|
||||||
|
if (!$user->email && !$confirm_email) {
|
||||||
|
$confirm_email = Confirm_address::staticGet('user_id', $user->id);
|
||||||
|
if ($confirm_email && $confirm_email->address_type != 'email') {
|
||||||
|
# Skip non-email confirmations
|
||||||
|
$confirm_email = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!$user->email && !$confirm_email) {
|
if (!$user->email && !$confirm_email) {
|
||||||
$this->client_error(_('No registered email address for that user.'));
|
$this->client_error(_('No registered email address for that user.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Success! We have a valid user and a confirmed or unconfirmed email address
|
||||||
|
|
||||||
$confirm = new Confirm_address();
|
$confirm = new Confirm_address();
|
||||||
$confirm->code = common_confirmation_code(128);
|
$confirm->code = common_confirmation_code(128);
|
||||||
$confirm->address_type = 'recover';
|
$confirm->address_type = 'recover';
|
||||||
$confirm->user_id = $user->id;
|
$confirm->user_id = $user->id;
|
||||||
$confirm->address = ($user->email) ? $user->email : $confirm_email->address;
|
$confirm->address = (isset($user->email)) ? $user->email : $confirm_email->address;
|
||||||
|
|
||||||
if (!$confirm->insert()) {
|
if (!$confirm->insert()) {
|
||||||
common_log_db_error($confirm, 'INSERT', __FILE__);
|
common_log_db_error($confirm, 'INSERT', __FILE__);
|
||||||
@ -244,7 +258,7 @@ class RecoverpasswordAction extends Action {
|
|||||||
$body .= common_config('site', 'name');
|
$body .= common_config('site', 'name');
|
||||||
$body .= "\n";
|
$body .= "\n";
|
||||||
|
|
||||||
mail_to_user($user, _('Password recovery requested'), $body);
|
mail_to_user($user, _('Password recovery requested'), $body, $confirm->address);
|
||||||
|
|
||||||
common_show_header(_('Password recovery requested'));
|
common_show_header(_('Password recovery requested'));
|
||||||
common_element('p', NULL,
|
common_element('p', NULL,
|
||||||
|
Loading…
Reference in New Issue
Block a user