Merge branch 'sessionidparam' of http://git.gitorious.org/~evan/statusnet/evans-mainline into sessionidparam
This commit is contained in:
commit
6f9bdc5b8a
@ -132,12 +132,6 @@ class LoginAction extends Action
|
||||
|
||||
$url = common_get_returnto();
|
||||
|
||||
if (common_config('site', 'ssl') == 'sometimes' && // mixed environment
|
||||
0 != strcasecmp(common_config('site', 'server'), common_config('site', 'sslserver'))) {
|
||||
$this->redirectFromSSL($user, $url, $this->boolean('rememberme'));
|
||||
return;
|
||||
}
|
||||
|
||||
if ($url) {
|
||||
// We don't have to return to it again
|
||||
common_set_returnto(null);
|
||||
@ -282,31 +276,4 @@ class LoginAction extends Action
|
||||
$nav = new LoginGroupNav($this);
|
||||
$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);
|
||||
}
|
||||
}
|
||||
|
@ -260,16 +260,6 @@ class RegisterAction extends Action
|
||||
// Re-init language env in case it changed (not yet, but soon)
|
||||
common_init_language();
|
||||
|
||||
if (common_config('site', 'ssl') == 'sometimes' && // mixed environment
|
||||
0 != strcasecmp(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();
|
||||
} else {
|
||||
$this->showForm(_('Invalid username or password.'));
|
||||
@ -589,32 +579,5 @@ class RegisterAction extends Action
|
||||
$nav = new LoginGroupNav($this);
|
||||
$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);
|
||||
}
|
||||
}
|
||||
|
||||
|
23
lib/util.php
23
lib/util.php
@ -809,14 +809,33 @@ function common_path($relative, $ssl=false)
|
||||
} else if (common_config('site', 'server')) {
|
||||
$serverpart = common_config('site', 'server');
|
||||
} else {
|
||||
common_log(LOG_ERR, 'Site Sever not configured, unable to determine site name.');
|
||||
common_log(LOG_ERR, 'Site server not configured, unable to determine site name.');
|
||||
}
|
||||
} else {
|
||||
$proto = 'http';
|
||||
if (common_config('site', 'server')) {
|
||||
$serverpart = common_config('site', 'server');
|
||||
} else {
|
||||
common_log(LOG_ERR, 'Site Sever not configured, unable to determine site name.');
|
||||
common_log(LOG_ERR, 'Site server not configured, unable to determine site name.');
|
||||
}
|
||||
}
|
||||
|
||||
if (common_have_session()) {
|
||||
|
||||
$currentServer = $_SERVER['HTTP_HOST'];
|
||||
|
||||
// Are we pointing to another server (like an SSL server?)
|
||||
|
||||
if (!empty($currentServer) &&
|
||||
0 != strcasecmp($currentServer, $serverpart)) {
|
||||
// Pass the session ID as a GET parameter
|
||||
$sesspart = session_name() . '=' . session_id();
|
||||
$i = strpos($relative, '?');
|
||||
if ($i === false) { // no GET params, just append
|
||||
$relative .= '?' . $sesspart;
|
||||
} else {
|
||||
$relative = substr($relative, 0, $i + 1).$sesspart.'&'.substr($relative, $i + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user