forked from GNUsocial/gnu-social
Use OTP to set cookies from registration action
This commit is contained in:
parent
5ca41b6870
commit
6d66a28b35
@ -259,6 +259,16 @@ class RegisterAction extends Action
|
|||||||
|
|
||||||
// Re-init language env in case it changed (not yet, but soon)
|
// Re-init language env in case it changed (not yet, but soon)
|
||||||
common_init_language();
|
common_init_language();
|
||||||
|
|
||||||
|
if (common_config('ssl', 'sometimes') && // mixed environment
|
||||||
|
common_config('site', 'server') != common_config('site', 'sslserver')) {
|
||||||
|
$url = common_local_url('all',
|
||||||
|
array('nickname' =>
|
||||||
|
$user->nickname));
|
||||||
|
$this->redirectFromSSL($user, $url, $this->boolean('rememberme'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$this->showSuccess();
|
$this->showSuccess();
|
||||||
} else {
|
} else {
|
||||||
$this->showForm(_('Invalid username or password.'));
|
$this->showForm(_('Invalid username or password.'));
|
||||||
@ -578,5 +588,32 @@ class RegisterAction extends Action
|
|||||||
$nav = new LoginGroupNav($this);
|
$nav = new LoginGroupNav($this);
|
||||||
$nav->show();
|
$nav->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function redirectFromSSL($user, $returnto, $rememberme)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$login_token = Login_token::makeNew($user);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$this->serverError($e->getMessage());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$params = array();
|
||||||
|
|
||||||
|
if (!empty($returnto)) {
|
||||||
|
$params['returnto'] = $returnto;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($rememberme)) {
|
||||||
|
$params['rememberme'] = $rememberme;
|
||||||
|
}
|
||||||
|
|
||||||
|
$target = common_local_url('otp',
|
||||||
|
array('user_id' => $login_token->user_id,
|
||||||
|
'token' => $login_token->token),
|
||||||
|
$params);
|
||||||
|
|
||||||
|
common_redirect($target, 303);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user