web - login messages
This commit is contained in:
parent
357dda7b5f
commit
84b94ac653
@ -10,6 +10,9 @@ append content
|
|||||||
div(class="uk-width-auto uk-width-1-4@s")
|
div(class="uk-width-auto uk-width-1-4@s")
|
||||||
.uk-flex.uk-flex-auto.uk-flex-column.uk-flex-center.uk-margin-left.uk-margin-right
|
.uk-flex.uk-flex-auto.uk-flex-column.uk-flex-center.uk-margin-left.uk-margin-right
|
||||||
h1= login_title || "Please login"
|
h1= login_title || "Please login"
|
||||||
|
#login_msg.uk-alert(data-uk-alert).uk-hidden
|
||||||
|
a.uk-close-alt.uk-alert-close(href="#")
|
||||||
|
p
|
||||||
form.uk-form-horizontal
|
form.uk-form-horizontal
|
||||||
.uk-margin
|
.uk-margin
|
||||||
label.uk-form-label(for="login_user") Username / Email
|
label.uk-form-label(for="login_user") Username / Email
|
||||||
|
@ -13,7 +13,19 @@ function login() {
|
|||||||
ajax.send(JSON.stringify(data));
|
ajax.send(JSON.stringify(data));
|
||||||
ajax.onload = () => {
|
ajax.onload = () => {
|
||||||
let json = JSON.parse(ajax.responseText);
|
let json = JSON.parse(ajax.responseText);
|
||||||
if(json.message && json.message == "msg.auth.login.successful") window.location.href= "/";
|
let box = document.getElementById("login_msg");
|
||||||
|
if(json.message && json.message == "msg.auth.login.successful") {
|
||||||
|
if(window.location.pathname == "/authenticate" && getParameterByName("appId")) window.location.href= "/authenticate";
|
||||||
|
else window.location.href= "/";
|
||||||
|
|
||||||
|
box.classList.remove("uk-hidden");
|
||||||
|
box.classList.add("uk-alert-success");
|
||||||
|
box.classList.getElementsByTagName("p")[0].innerHTML = "Logged in. You will be redirected";
|
||||||
|
} else if(json.message && json.message == "msg.auth.login.failed") {
|
||||||
|
box.classList.remove("uk-hidden");
|
||||||
|
box.classList.add("uk-alert-danger");
|
||||||
|
box.getElementsByTagName("p")[0].innerHTML = "Login failed.<br> Username or Password is wrong.";
|
||||||
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -33,3 +45,14 @@ setTimeout(function () {
|
|||||||
logout();
|
logout();
|
||||||
}
|
}
|
||||||
}, 100);
|
}, 100);
|
||||||
|
|
||||||
|
// @url: https://stackoverflow.com/a/901144
|
||||||
|
function getParameterByName(name) {
|
||||||
|
let url = window.location.href;
|
||||||
|
name = name.replace(/[\[\]]/g, '\\$&');
|
||||||
|
var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'),
|
||||||
|
results = regex.exec(url);
|
||||||
|
if (!results) return null;
|
||||||
|
if (!results[2]) return '';
|
||||||
|
return decodeURIComponent(results[2].replace(/\+/g, ' '));
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user