summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorroot <root@ip-10-250-162-129.ec2.internal>2010-01-10 00:24:20 +0000
committerroot <root@ip-10-250-162-129.ec2.internal>2010-01-10 00:24:20 +0000
commit4ffc28e1a5ffa38e3a8b670690ef5764e4edeefb (patch)
tree6b7328df2c92b1a1d57b00db3252646b0151a019
parent1b9fd1fe5311b3af9e22e64fac37e5b9fe93c4a3 (diff)
parent6d66a28b3591b579f0230620339882e9ba8078ab (diff)
Merge branch 'redironlogin' of http://git.gitorious.org/~evan/statusnet/evans-mainline into redironlogin
-rw-r--r--actions/register.php37
-rw-r--r--classes/Status_network.php18
2 files changed, 49 insertions, 6 deletions
diff --git a/actions/register.php b/actions/register.php
index 57f8e7bdf..108d05f5a 100644
--- a/actions/register.php
+++ b/actions/register.php
@@ -259,6 +259,16 @@ class RegisterAction extends Action
// Re-init language env in case it changed (not yet, but soon)
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();
} else {
$this->showForm(_('Invalid username or password.'));
@@ -578,5 +588,32 @@ 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);
+ }
}
diff --git a/classes/Status_network.php b/classes/Status_network.php
index b3117640d..8dff879df 100644
--- a/classes/Status_network.php
+++ b/classes/Status_network.php
@@ -150,9 +150,18 @@ class Status_network extends DB_DataObject
}
if (!empty($sn)) {
- if (!empty($sn->hostname) && 0 != strcasecmp($sn->hostname, $servername)) {
- $sn->redirectToHostname();
+
+ // Redirect to the right URL
+
+ if (!empty($sn->hostname) &&
+ empty($SERVER['HTTPS']) &&
+ 0 != strcasecmp($sn->hostname, $servername)) {
+ $sn->redirectTo('http://'.$sn->hostname.$_SERVER['REQUEST_URI']);
+ } else if (!empty($SERVER['HTTPS']) &&
+ 0 != strcasecmp($sn->sitename.'.'.$wildcard, $servername)) {
+ $sn->redirectTo('https://'.$sn->sitename.'.'.$wildcard.$_SERVER['REQUEST_URI']);
}
+
$dbhost = (empty($sn->dbhost)) ? 'localhost' : $sn->dbhost;
$dbuser = (empty($sn->dbuser)) ? $sn->nickname : $sn->dbuser;
$dbpass = $sn->dbpass;
@@ -179,11 +188,8 @@ class Status_network extends DB_DataObject
// (C) 2006 by Heiko Richler http://www.richler.de/
// LGPL
- function redirectToHostname()
+ function redirectTo($destination)
{
- $destination = 'http://'.$this->hostname;
- $destination .= $_SERVER['REQUEST_URI'];
-
$old = 'http'.
(($_SERVER['HTTPS'] == 'on') ? 'S' : '').
'://'.