Commit fd5b1e9a authored by Leigh B Stoller's avatar Leigh B Stoller

After CloudLab login, redirect to myexperments.php or instantiate.php.

parent f41db731
......@@ -194,5 +194,15 @@ class Instance
}
return array($instance, $creator);
}
function UserHasInstances($user) {
$uuid = $user->uuid();
$query_result =
DBQueryFatal("select uuid from apt_instances ".
"where creator_uuid='$uuid'");
return mysql_num_rows($query_result);
}
}
?>
......@@ -25,6 +25,7 @@ chdir("..");
include("defs.php3");
chdir("apt");
include("quickvm_sup.php");
include("instance_defs.php");
$page_title = "Login";
#
......@@ -160,8 +161,16 @@ function SPITFORM($uid, $referrer, $error)
# If not clicked, then put up a form.
#
if (!$ajax_request && !isset($login)) {
SPITFORM(REMEMBERED_ID(), $referrer,
($this_user ? "alreadyloggedin" : null));
if ($this_user) {
if (Instance::UserHasInstances($this_user)) {
header("Location: $APTBASE/myexperments.php");
}
else {
header("Location: $APTBASE/instantiate.php");
}
return;
}
SPITFORM(REMEMBERED_ID(), $referrer, null);
return;
}
......@@ -232,9 +241,11 @@ elseif (isset($referrer)) {
header("Location: $referrer");
}
else {
#
# Zap back to front page in secure mode.
#
header("Location: $APTBASE/instantiate.php");
if (Instance::UserHasInstances($CHECKLOGIN_USER)) {
header("Location: $APTBASE/myexperments.php");
}
else {
header("Location: $APTBASE/instantiate.php");
}
}
?>
......@@ -52,7 +52,7 @@ if ($TBMAINSITE && $_SERVER["SERVER_NAME"] == "www.aptlab.net") {
$APTBASE = "https://www.aptlab.net";
$APTMAIL = "APT Operations <testbed-ops@aptlab.net>";
}
elseif ($TBMAINSITE && $_SERVER["SERVER_NAME"] == "www.cloudlab.us") {
elseif (($TBMAINSITE && $_SERVER["SERVER_NAME"] == "www.cloudlab.us")) {
$ISVSERVER = 1;
$TBAUTHDOMAIN = ".cloudlab.us";
$APTHOST = "www.cloudlab.us";
......@@ -170,14 +170,16 @@ function SPITHEADER($thinheader = 0)
href='signup.php'>
Sign Up</a></form></li>
\n";
echo "<li id='loginitem' class='apt-left'>" .
"<form><a class='btn btn-primary navbar-btn'
if ($page_title != "Login") {
echo "<li id='loginitem' class='apt-left'>" .
"<form><a class='btn btn-primary navbar-btn'
id='loginbutton'
data-toggle='modal'
href='#quickvm_login_modal'
data-target='#quickvm_login_modal'>
Login</a></form></li>
\n";
\n";
}
}
else {
echo "<li class='apt-left'>" .
......
......@@ -786,7 +786,7 @@ function DOLOGIN($token, $password, $adminmode = 0, $nopassword = 0) {
global $TBNAMECOOKIE, $TBLOGINCOOKIE, $TBSECURECOOKIES;
global $TBMAIL_OPS, $TBMAIL_AUDIT, $TBMAIL_WWW;
global $WIKISUPPORT, $WIKICOOKIENAME;
global $BUGDBSUPPORT, $BUGDBCOOKIENAME;
global $BUGDBSUPPORT, $BUGDBCOOKIENAME, $CHECKLOGIN_USER;
# Caller makes these checks too.
if ((!TBvalid_uid($token) && !TBvalid_email($token)) ||
......@@ -896,6 +896,7 @@ function DOLOGIN($token, $password, $adminmode = 0, $nopassword = 0) {
if (DOLOGIN_MAGIC($uid, $uid_idx, $usr_email, $adminon) < 0) {
return DOLOGIN_STATUS_ERROR;
}
$CHECKLOGIN_USER = $user;
#
# Usage stats.
......
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