Login and Singnup with Auth0 ready

This commit is contained in:
Luis Fernando Molina committed 2018-08-10 21:11:37 +02:00
1 parent ebe3026d3b
commit bc292b44b2
3 files changed
+60 -10

No files matched your search

+1 -1
View File
@@ -20,7 +20,7 @@ function newDashboard() {
start: start
};
const DEBUG_START_UP_DELAY = 0 //3000; // This is a waiting time in case there is a need to debug the very first steps of initialization, to be able to hit F12 on time.
const DEBUG_START_UP_DELAY = 0; //3000; // This is a waiting time in case there is a need to debug the very first steps of initialization, to be able to hit F12 on time.
return thisObject;
+55 -8
View File
@@ -21,29 +21,64 @@ function newLogin() {
container.isDraggeable = false;
container.isClickeable = true;
const LOGIN_URL = "https://advancedalgos1.eu.auth0.com/login?state=HQmR_JEnoSYS9Zz0nkCzW_zALsRJXjoQ&client=GReymhOiUQuLhDEwxlLu6PMDIa6mjVQQ&protocol=oauth2&response_type=token%20id_token&redirect_uri=https%3A%2F%2F" + window.location.host + "%2F%23&scope=openid&audience=https%3A%2F%2Fadvancedalgos1.eu.auth0.com%2Fuserinfo&nonce=7LZ5hOd6D3jFdNdtDvEqNOyOR3nZXw5A&auth0Client=eyJuYW1lIjoiYXV0aDAuanMiLCJ2ZXJzaW9uIjoiOS41LjEifQ%3D%3D"
const AUTH0_CLIENT_ID = 'WQTnXt20a0t2WGl64mEcOyP4Ippo37nB';
const AUTH0_DOMAIN = 'advancedalgos.eu.auth0.com';
const LOGIN_URL = "https://" + AUTH0_DOMAIN + "/authorize" +
"?state=" +
"&client_id=" + AUTH0_CLIENT_ID +
"&response_type=id_token" +
"&redirect_uri=" + location.href + "index.html" +
"&scope=openid" +
"&nonce=CALCULATESOMENONCE";
const LOGOUT_URL = "/";
let currentURL;
let currentLabel;
let sharedStatus;
let Auth0;
let userAuthorization;
return thisObject;
function initialize() {
let parameters = {
domain: 'advancedalgos.eu.auth0.com',
redirectUri: window.location.href,
clientID: 'WQTnXt20a0t2WGl64mEcOyP4Ippo37nB'
};
if (window.USER_LOGGED_IN === "") {
Auth0 = new auth0.WebAuth(parameters);
currentLabel = "Login";
currentURL = LOGIN_URL;
userAuthorization = window.location.hash.substr(1); // What comes after the # on the URL.
if (userAuthorization === "") {
currentLabel = "Login / Signup";
} else {
currentLabel = "Logout";
currentURL = LOGOUT_URL;
console.log(userAuthorization);
Auth0.parseHash({ hash: window.location.hash }, function (err, authResult) {
if (err) {
return console.log(err);
}
console.log(err);
console.log(authResult);
// The contents of authResult depend on which authentication parameters were used.
// It can include the following:
// authResult.accessToken - access token for the API specified by `audience`
// authResult.expiresIn - string with the access token's expiration time in seconds
// authResult.idToken - ID token JWT containing user profile information
currentLabel = "Logout";
});
}
thisObject.container.eventHandler.listenToEvent("onMouseClick", onClick);
@@ -51,8 +86,20 @@ function newLogin() {
function onClick() {
window.location.href = currentURL;
if (userAuthorization === "") {
/* Goes for a login / signup */
Auth0.authorize({
scope: 'openid profile',
responseType: 'id_token'
});
} else {
/* Goes for a logout */
}
}
function getContainer(point) {
+4 -1
View File
@@ -3,7 +3,8 @@
<head>
<meta charset="utf-8" />
<title>Advanced Algos</title>
<script type="text/javascript" src="https://cdn.auth0.com/js/auth0/9.7.3/auth0.min.js"></script>
<script type="text/javascript" src="Scripts/Require.js"></script>
<script type="text/javascript" src="Scripts/AppPreLoader.js"></script>
@@ -15,6 +16,8 @@
</head>
<body id="body" style="margin: 0px; padding: 0px; border: 0px; overflow:hidden;" onload="
window.SESSION_TOKEN = '';
loadAdvancedAlgosPlatform();