Continued work on remember me tokens.
This commit is contained in:
parent
95ed2fa403
commit
e00e5a608b
11 changed files with 113 additions and 36 deletions
|
|
@ -21,6 +21,8 @@ class registerPrompt{
|
|||
this.user.value = window.location.search.replace("?user=",'');
|
||||
//Grab pass prompts
|
||||
this.pass = document.querySelector("#login-page-password");
|
||||
//Remember me checkbox
|
||||
this.rememberMe = document.querySelector("#login-page-remember-me");
|
||||
//Grab register button
|
||||
this.button = document.querySelector("#login-page-button");
|
||||
//Grab altcha widget
|
||||
|
|
@ -58,10 +60,10 @@ class registerPrompt{
|
|||
}
|
||||
|
||||
//login with verification
|
||||
utils.ajax.login(this.user.value , this.pass.value, this.verification);
|
||||
utils.ajax.login(this.user.value , this.pass.value, this.rememberMe.checked, this.verification);
|
||||
}else{
|
||||
//login
|
||||
utils.ajax.login(this.user.value, this.pass.value);
|
||||
utils.ajax.login(this.user.value, this.pass.value, this.rememberMe.checked);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ async function navbarLogin(event){
|
|||
if(!event || !event.key || event.key == "Enter"){
|
||||
var user = document.querySelector("#username-prompt").value;
|
||||
var pass = document.querySelector("#password-prompt").value;
|
||||
var rememberMe = document.querySelector("#remember-me").checked;
|
||||
|
||||
//If no user or pass is presented
|
||||
if(user == "" || pass == ""){
|
||||
|
|
@ -26,7 +27,7 @@ async function navbarLogin(event){
|
|||
window.location = '/login'
|
||||
}
|
||||
|
||||
utils.ajax.login(user, pass);
|
||||
utils.ajax.login(user, pass, rememberMe);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -755,14 +755,14 @@ class canopyAjaxUtils{
|
|||
}
|
||||
}
|
||||
|
||||
async login(user, pass, verification){
|
||||
async login(user, pass, rememberMe, verification){
|
||||
const response = await fetch(`/api/account/login`,{
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"x-csrf-token": utils.ajax.getCSRFToken()
|
||||
},
|
||||
body: JSON.stringify(verification ? {user, pass, verification} : {user, pass})
|
||||
body: JSON.stringify(verification ? {user, pass, rememberMe, verification} : {user, rememberMe, pass})
|
||||
});
|
||||
|
||||
if(response.ok){
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue