Skip to content

Commit

Permalink
Merge pull request #28 from 2i2c-org/utoronto-staging
Browse files Browse the repository at this point in the history
Redirect utoronto home pages more selectively
  • Loading branch information
yuvipanda authored Jan 9, 2024
2 parents 154327a + 97c6518 commit f6241bc
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 436 deletions.
81 changes: 0 additions & 81 deletions extra-assets/css/login.css

This file was deleted.

Binary file removed extra-assets/images/home-hero.png
Binary file not shown.
88 changes: 0 additions & 88 deletions extra-assets/images/jupyter-logo.svg

This file was deleted.

70 changes: 0 additions & 70 deletions extra-assets/images/rstudio-logo.svg

This file was deleted.

50 changes: 19 additions & 31 deletions extra-assets/js/login.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,20 @@
function redirectIfNeeded() {
// Only redirect utoronto.2i2c.cloud, lets us keep staging at staging.utoronto.2i2c.cloud
if (window.location.hostname === 'utoronto.2i2c.cloud') {
// Let's give users an indication that something is happening
document.write("Redirecting you to jupyter.utoronto.ca");
window.location.hostname = 'jupyter.utoronto.ca';
}
// This code must be run *as early as possible*, as we care about redirecting the user
// *somewhere* immediately. So this isn't wrapped in a window.onload or similar, but bare.
// This code is also loaded directly in <head>, so it will block page load.
const curUrl = new URL(document.location);
// if next query param is presentm just do nothing
const nextUrl = curUrl.searchParams.get('next');
// /hub/ being next should be treated same as no next present
if (!nextUrl || nextUrl === "/hub/") {
// The 'unified' home page for all the hubs is at https://datatools.utoronto.ca,
// so anyone landing on the home page should just be redirected.
window.location.replace("https://datatools.utoronto.ca");
} else {
// The user has landed on this page, which means they are not actually logged in,
// and need to login to continue to wherever they are going. So let's construct the
// appropriate oauth_login URL for them to go to.
let oauthLoginUrl = new URL(document.location);
// Pass along all url parameters we got, just change from /login to /oauth_login
oauthLoginUrl.pathname = "/oauth_login";
window.location.replace(oauthLoginUrl);
}
function setInterface(interfaceUrl) {
let loginUrl = new URL($('#home').data('authenticator-login-url'), document.location.origin);
loginUrl.searchParams.set('next', '/hub/user-redirect/' + interfaceUrl)
$('#login-button').attr(
'href',
loginUrl.toString()
);
}
$(function() {
redirectIfNeeded();
// if next query param is presentm just do nothing
const nextPresent = new URL(document.location).searchParams.get('next');
// /hub/ being next should be treated same as no next present
if (!nextPresent || nextPresent === "/hub/") {
setInterface($("input[name='interface']:checked").val());

$("input[name='interface']").change(function() {
if (this.checked) {
setInterface(this.value)
}
});
}

})
12 changes: 4 additions & 8 deletions templates/error.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% extends "templates/error.html" %}

{% block error_detail %}
{% if status_code == 403 %}
{% if status_code == 500 %}
<style>
.info {
color: #fc8703;
Expand All @@ -17,13 +17,9 @@
</style>
<div class="error">
<div class="info">
<i class="fa fa-info-circle"></i>
Looks like you have <b>NOT</b> been added to the list of allowed users for this hub. Please contact the hub administrators.
</div>
<div class="text-center">
<a role="button" class='btn btn-jupyter' href='{{base_url}}/logout'>
Tap to try a different account
</a>
<i class="fa fa-info-circle"></i>
We are investigating an issue that causes login failures for some users.
As a temporary workaround, please login to <a href="https://mail.utoronto.ca">mail.utoronto.ca</a> first, and then you should be able to login to the JupyterHub.
</div>
</div>
{% else %}
Expand Down
Loading

0 comments on commit f6241bc

Please sign in to comment.