We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

Commit 206376cf authored by Evan Prodromou's avatar Evan Prodromou

use Start/EndRegistrationTry events for email registration

parent 6267ea2e
...@@ -252,44 +252,55 @@ class EmailregisterAction extends Action ...@@ -252,44 +252,55 @@ class EmailregisterAction extends Action
function setPassword() function setPassword()
{ {
if (!empty($this->invitation)) { if (Event::handle('StartRegistrationTry', array($this))) {
$email = $this->invitation->address; if (!empty($this->invitation)) {
} else if (!empty($this->confirmation)) { $email = $this->invitation->address;
$email = $this->confirmation->address; } else if (!empty($this->confirmation)) {
} else { $email = $this->confirmation->address;
throw new Exception('No confirmation thing.'); } else {
} throw new Exception('No confirmation thing.');
}
if (!$this->tos) {
$this->error = _('You must accept the terms of service and privacy policy to register.');
$nickname = $this->nicknameFromEmail($email);
$this->form = new ConfirmRegistrationForm($this, $nickname, $this->email, $this->code);
$this->showPage();
return;
}
if (!$this->tos) {
$this->error = _('You must accept the terms of service and privacy policy to register.');
$nickname = $this->nicknameFromEmail($email); $nickname = $this->nicknameFromEmail($email);
$this->form = new ConfirmRegistrationForm($this, $nickname, $this->email, $this->code);
$this->showPage();
return;
}
$nickname = $this->nicknameFromEmail($email); $this->user = User::register(array('nickname' => $nickname,
'email' => $email,
'email_confirmed' => true));
if (empty($this->user)) {
throw new Exception("Failed to register user.");
}
$this->user = User::register(array('nickname' => $nickname, common_set_user($this->user);
'email' => $email, // this is a real login
'email_confirmed' => true)); common_real_login(true);
if (empty($this->user)) { // Re-init language env in case it changed (not yet, but soon)
throw new Exception("Failed to register user."); 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)) {
Subscription::start($inviter->getProfile(), Subscription::start($inviter->getProfile(),
$user->getProfile()); $user->getProfile());
}
$this->invitation->delete();
} else if (!empty($this->confirmation)) {
$this->confirmation->delete();
} else {
throw new Exception('No confirmation thing.');
} }
$this->invitation->delete(); Event::handle('EndRegistrationTry', array($this));
} else if (!empty($this->confirmation)) {
$this->confirmation->delete();
} else {
throw new Exception('No confirmation thing.');
} }
common_redirect(common_local_url('doc', array('title' => 'welcome')), common_redirect(common_local_url('doc', array('title' => 'welcome')),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment