use Start/EndRegistrationTry events for email registration

This commit is contained in:
Evan Prodromou 2011-04-18 06:46:16 -04:00
parent 6267ea2e8d
commit 206376cf10

View File

@ -252,6 +252,7 @@ class EmailregisterAction extends Action
function setPassword() function setPassword()
{ {
if (Event::handle('StartRegistrationTry', array($this))) {
if (!empty($this->invitation)) { if (!empty($this->invitation)) {
$email = $this->invitation->address; $email = $this->invitation->address;
} else if (!empty($this->confirmation)) { } else if (!empty($this->confirmation)) {
@ -278,6 +279,13 @@ class EmailregisterAction extends Action
throw new Exception("Failed to register user."); throw new Exception("Failed to register user.");
} }
common_set_user($this->user);
// this is a real login
common_real_login(true);
// Re-init language env in case it changed (not yet, but soon)
common_init_language();
if (!empty($this->invitation)) { if (!empty($this->invitation)) {
$inviter = User::staticGet('id', $this->invitation->user_id); $inviter = User::staticGet('id', $this->invitation->user_id);
if (!empty($inviter)) { if (!empty($inviter)) {
@ -292,6 +300,9 @@ class EmailregisterAction extends Action
throw new Exception('No confirmation thing.'); throw new Exception('No confirmation thing.');
} }
Event::handle('EndRegistrationTry', array($this));
}
common_redirect(common_local_url('doc', array('title' => 'welcome')), common_redirect(common_local_url('doc', array('title' => 'welcome')),
303); 303);
} }