Commit 92358d56 authored by Leigh Stoller's avatar Leigh Stoller

Watch for and notify guest users if they try to create more then one

experiment.
parent 970dee17
......@@ -363,7 +363,8 @@ if (!isset($create)) {
#
$instance = Instance::LookupByCreator($geniuser->uuid());
if ($instance && $instance->status() != "terminating") {
header("Location: status.php?uuid=" . $instance->uuid());
header("Location: status.php?oneonly=1&uuid=" .
$instance->uuid());
return;
}
$defaults["username"] = $geniuser->name();
......@@ -516,7 +517,8 @@ if (!$this_user &&
setcookie("quickvm_user",
$geniuser->uuid(), time() + (24 * 3600 * 30),
"/", $TBAUTHDOMAIN, 0);
header("Location: status.php?uuid=" . $instance->uuid());
header("Location: status.php?oneonly=1&uuid=" .
$instance->uuid());
return;
}
}
......
......@@ -8,16 +8,18 @@ require(window.APT_OPTIONS.configObject,
'js/lib/text!template/extend-modal.html',
'js/lib/text!template/clone-help.html',
'js/lib/text!template/snapshot-help.html',
'js/lib/text!template/oneonly-modal.html',
'tablesorter', 'tablesorterwidgets'],
function (_, sup, moment, ShowImagingModal,
statusString, waitwaitString, oopsString,
registerString, terminateString, extendString,
cloneHelpString, snapshotHelpString)
cloneHelpString, snapshotHelpString, oneonlyString)
{
'use strict';
var nodecount = 0;
var ajaxurl = null;
var uuid = null;
var oneonly = 0;
var status_collapsed = false;
var status_message = "";
var statusTemplate = _.template(statusString);
......@@ -26,12 +28,14 @@ function (_, sup, moment, ShowImagingModal,
var registerTemplate = _.template(registerString);
var terminateTemplate = _.template(terminateString);
var extendTemplate = _.template(extendString);
var oneonlyTemplate = _.template(oneonlyString);
function initialize()
{
window.APT_OPTIONS.initialize(sup);
ajaxurl = window.APT_OPTIONS.AJAXURL;
uuid = window.APT_OPTIONS.uuid;
oneonly = window.APT_OPTIONS.oneonly;
var instanceStatus = window.APT_OPTIONS.instanceStatus;
// Generate the templates.
......@@ -59,6 +63,8 @@ function (_, sup, moment, ShowImagingModal,
$('#extend_div').html(extend_html);
var terminate_html = terminateTemplate(template_args);
$('#terminate_div').html(terminate_html);
var oneonly_html = oneonlyTemplate(template_args);
$('#oneonly_div').html(oneonly_html);
//
// Look at initial status to determine if we show the progress bar.
......@@ -238,7 +244,10 @@ function (_, sup, moment, ShowImagingModal,
StartCountdownClock(window.APT_OPTIONS.sliceExpires);
GetStatus(uuid);
if (window.APT_OPTIONS.snapping) {
if (window.APT_OPTIONS.oneonly) {
sup.ShowModal('#oneonly-modal');
}
else if (window.APT_OPTIONS.snapping) {
ShowProgressModal();
}
}
......@@ -761,7 +770,7 @@ function (_, sup, moment, ShowImagingModal,
/*
* If a single node, show the clone button and maybe the
* the snapshot; the user must own the profile it was
* created from in order to do a snapshot.
* created from in order to do a snapshot.
*/
if (nodecount == 1) {
$("#clone_button").removeClass("hidden");
......@@ -773,7 +782,7 @@ function (_, sup, moment, ShowImagingModal,
}
// And start up ssh for single node topologies.
if (nodecount == 1 && nodehostport) {
if (nodecount == 1 && nodehostport && !oneonly) {
NewSSHTab(nodehostport, nodename);
}
}
......
......@@ -41,7 +41,8 @@ $this_user = CheckLogin($check_status);
#
# Verify page arguments.
#
$reqargs = OptionalPageArguments("uuid", PAGEARG_STRING);
$reqargs = OptionalPageArguments("uuid", PAGEARG_STRING,
"oneonly", PAGEARG_BOOLEAN);
if (!isset($uuid)) {
SPITHEADER(1);
......@@ -118,6 +119,7 @@ $cansnap = ((isset($this_user) &&
$this_user->idx() == $profile->creator_idx()) ||
ISADMIN() ? 1 : 0);
$snapping = 0;
$oneonly = (isset($oneonly) && $oneonly ? 1 : 0);
#
# See if we have a task running in the background for this instance.
......@@ -154,6 +156,7 @@ echo " window.APT_OPTIONS.creatorEmail = '" . $creator_email . "';\n";
echo " window.APT_OPTIONS.registered = $registered;\n";
echo " window.APT_OPTIONS.cansnap = $cansnap;\n";
echo " window.APT_OPTIONS.snapping = $snapping;\n";
echo " window.APT_OPTIONS.oneonly = $oneonly;\n";
echo " window.APT_OPTIONS.AJAXURL = 'server-ajax.php';\n";
echo "</script>\n";
echo "<script src='js/lib/jquery-2.0.3.min.js'></script>\n";
......
<!-- This is the One-Only modal -->
<div id='oneonly-modal' class='modal fade'>
<div class='modal-dialog'>
<div class='modal-content'>
<div class='modal-body'>
<p>You have another experiment registered with this email
address. Guest users in Apt are allowed one experiment at a
time. You can return to your existing experiment, or register for
an account if you like to make a new one.
</p>
<br>
<center>
<button type='button' style='margin-right: 20px;'
class='btn btn-success btn-sm'
data-dismiss='modal' aria-hidden='true'>
Return to Experiment</button>
<a class='btn btn-primary btn-sm' href='signup.php'>
Register</a>
</div>
</div>
</div>
</div>
......@@ -190,4 +190,5 @@
<div id='register_div'></div>
<div id='extend_div'></div>
<div id='imaging_div'></div>
<div id='oneonly_div'></div>
</div>
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