use Start/EndRegistrationTry events for email registration
This commit is contained in:
parent
6267ea2e8d
commit
206376cf10
@ -252,44 +252,55 @@ class EmailregisterAction extends Action
|
||||
|
||||
function setPassword()
|
||||
{
|
||||
if (!empty($this->invitation)) {
|
||||
$email = $this->invitation->address;
|
||||
} else if (!empty($this->confirmation)) {
|
||||
$email = $this->confirmation->address;
|
||||
} 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;
|
||||
}
|
||||
|
||||
$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.");
|
||||
}
|
||||
|
||||
if (!empty($this->invitation)) {
|
||||
$inviter = User::staticGet('id', $this->invitation->user_id);
|
||||
if (!empty($inviter)) {
|
||||
Subscription::start($inviter->getProfile(),
|
||||
$user->getProfile());
|
||||
if (Event::handle('StartRegistrationTry', array($this))) {
|
||||
if (!empty($this->invitation)) {
|
||||
$email = $this->invitation->address;
|
||||
} else if (!empty($this->confirmation)) {
|
||||
$email = $this->confirmation->address;
|
||||
} else {
|
||||
throw new Exception('No confirmation thing.');
|
||||
}
|
||||
|
||||
$this->invitation->delete();
|
||||
} else if (!empty($this->confirmation)) {
|
||||
$this->confirmation->delete();
|
||||
} 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;
|
||||
}
|
||||
|
||||
$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.");
|
||||
}
|
||||
|
||||
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)) {
|
||||
$inviter = User::staticGet('id', $this->invitation->user_id);
|
||||
if (!empty($inviter)) {
|
||||
Subscription::start($inviter->getProfile(),
|
||||
$user->getProfile());
|
||||
}
|
||||
|
||||
$this->invitation->delete();
|
||||
} else if (!empty($this->confirmation)) {
|
||||
$this->confirmation->delete();
|
||||
} else {
|
||||
throw new Exception('No confirmation thing.');
|
||||
}
|
||||
|
||||
Event::handle('EndRegistrationTry', array($this));
|
||||
}
|
||||
|
||||
common_redirect(common_local_url('doc', array('title' => 'welcome')),
|
||||
|
Loading…
Reference in New Issue
Block a user