Migration UI complete.
This commit is contained in:
parent
eb48b92551
commit
6bab5b4723
|
|
@ -56,8 +56,15 @@ module.exports.post = async function(req, res){
|
||||||
//Look for the username in the migration DB
|
//Look for the username in the migration DB
|
||||||
const migrationDB = await migrationModel.findOne({user});
|
const migrationDB = await migrationModel.findOne({user});
|
||||||
|
|
||||||
//If this isn't a migration
|
//If we found a migration profile
|
||||||
if(migrationDB == null){
|
if(migrationDB != null){
|
||||||
|
//If the user has a good password
|
||||||
|
if(hashUtils.compareLegacyPassword(pass, migrationDB.pass)){
|
||||||
|
//Redirect to migrate
|
||||||
|
return res.sendStatus(301);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//Get login attempts
|
//Get login attempts
|
||||||
const attempts = sessionUtils.getLoginAttempts(user)
|
const attempts = sessionUtils.getLoginAttempts(user)
|
||||||
|
|
||||||
|
|
@ -66,14 +73,6 @@ module.exports.post = async function(req, res){
|
||||||
//tell client it needs a captcha
|
//tell client it needs a captcha
|
||||||
return res.sendStatus(429);
|
return res.sendStatus(429);
|
||||||
}
|
}
|
||||||
//otherwise
|
|
||||||
}else{
|
|
||||||
//If the user has a good password
|
|
||||||
if(hashUtils.compareLegacyPassword(pass, migrationDB.pass)){
|
|
||||||
//Redirect to migrate
|
|
||||||
return res.sendStatus(301);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}else{
|
}else{
|
||||||
res.status(400);
|
res.status(400);
|
||||||
return res.send({errors: validResult.array()})
|
return res.send({errors: validResult.array()})
|
||||||
|
|
|
||||||
|
|
@ -225,7 +225,7 @@ module.exports.welcomeWagon = function(count, date, tokes){
|
||||||
\x1b[32m WEE EEE EED\x1b[0m C A A N NN O O P Y
|
\x1b[32m WEE EEE EED\x1b[0m C A A N NN O O P Y
|
||||||
\x1b[32m WEEEEED\x1b[0m CCCC A A N NN OOO P Y
|
\x1b[32m WEEEEED\x1b[0m CCCC A A N NN OOO P Y
|
||||||
\x1b[32m WEEE ! EEED\x1b[0m
|
\x1b[32m WEEE ! EEED\x1b[0m
|
||||||
\x1b[32m !\x1b[0m \x1b[34mInitialization Complete!\x1b[0m This server has booted \x1b[4m${count}\x1b[0m time${count == 1 ? '' : 's'} and taken ${tokes} \x1b[4mtoke${tokes == 1 ? '' : 's'}\x1b[0m.
|
\x1b[32m !\x1b[0m \x1b[34mInitialization Complete!\x1b[0m This server has booted \x1b[4m${count}\x1b[0m time${count == 1 ? '' : 's'} and taken \x1b[4m${tokes}\x1b[0m toke${tokes == 1 ? '' : 's'}.
|
||||||
\x1b[32m !\x1b[0m This server was first booted on \x1b[4m${date}\x1b[0m.`
|
\x1b[32m !\x1b[0m This server was first booted on \x1b[4m${date}\x1b[0m.`
|
||||||
|
|
||||||
//Dump art to console
|
//Dump art to console
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,9 @@ along with this program. If not, see <https://www.gnu.org/licenses/>. %>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<%- include('partial/navbar', {user}); %>
|
<%- include('partial/navbar', {user}); %>
|
||||||
|
<h1>Welcome Back!</h1>
|
||||||
|
<h2><%= instance%> has received an update, and your account needs one too!</h2>
|
||||||
|
<h2 class="danger-text">Remember your new password, you will need it for your first login!</h2>
|
||||||
<form action="javascript:">
|
<form action="javascript:">
|
||||||
<label>Username:</label>
|
<label>Username:</label>
|
||||||
<input class="migrate-prompt" id="migrate-username" placeholder="Required">
|
<input class="migrate-prompt" id="migrate-username" placeholder="Required">
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,8 @@ along with this program. If not, see <https://www.gnu.org/licenses/>. %>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<%- include('partial/navbar', {user}); %>
|
<%- include('partial/navbar', {user}); %>
|
||||||
|
<h1>Account Registration</h1>
|
||||||
|
<h2 class="danger-text">Remember your password, you will need it for your first login!</h2>
|
||||||
<form action="javascript:">
|
<form action="javascript:">
|
||||||
<label>Username:</label>
|
<label>Username:</label>
|
||||||
<input class="register-prompt" id="register-username" placeholder="Required">
|
<input class="register-prompt" id="register-username" placeholder="Required">
|
||||||
|
|
|
||||||
|
|
@ -29,3 +29,11 @@ form{
|
||||||
width: 6em;
|
width: 6em;
|
||||||
height: 2em;
|
height: 2em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
h1, h2{
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
h2{
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
@ -29,3 +29,7 @@ form{
|
||||||
width: 6em;
|
width: 6em;
|
||||||
height: 2em;
|
height: 2em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
h1, h2{
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
@ -18,6 +18,7 @@ class registerPrompt{
|
||||||
constructor(){
|
constructor(){
|
||||||
//Grab user prompt
|
//Grab user prompt
|
||||||
this.user = document.querySelector("#login-page-username");
|
this.user = document.querySelector("#login-page-username");
|
||||||
|
this.user.value = window.location.search.replace("?user=",'');
|
||||||
//Grab pass prompts
|
//Grab pass prompts
|
||||||
this.pass = document.querySelector("#login-page-password");
|
this.pass = document.querySelector("#login-page-password");
|
||||||
//Grab register button
|
//Grab register button
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ class migratePrompt{
|
||||||
constructor(){
|
constructor(){
|
||||||
//Grab user prompt
|
//Grab user prompt
|
||||||
this.user = document.querySelector("#migrate-username");
|
this.user = document.querySelector("#migrate-username");
|
||||||
|
this.user.value = window.location.search.replace("?user=",'');
|
||||||
//Grab pass prompts
|
//Grab pass prompts
|
||||||
this.oldPass = document.querySelector("#migrate-password-old");
|
this.oldPass = document.querySelector("#migrate-password-old");
|
||||||
this.pass = document.querySelector("#migrate-password");
|
this.pass = document.querySelector("#migrate-password");
|
||||||
|
|
@ -37,6 +38,8 @@ class migratePrompt{
|
||||||
//Add verification event listener to altcha widget
|
//Add verification event listener to altcha widget
|
||||||
this.altcha.addEventListener("verified", this.verify.bind(this));
|
this.altcha.addEventListener("verified", this.verify.bind(this));
|
||||||
|
|
||||||
|
console.log(this.button);
|
||||||
|
|
||||||
//Add migrate event listener to migrate button
|
//Add migrate event listener to migrate button
|
||||||
this.button.addEventListener("click", this.migrate.bind(this));
|
this.button.addEventListener("click", this.migrate.bind(this));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -756,7 +756,7 @@ class canopyAjaxUtils{
|
||||||
}
|
}
|
||||||
|
|
||||||
async login(user, pass, verification){
|
async login(user, pass, verification){
|
||||||
var response = await fetch(`/api/account/login`,{
|
const response = await fetch(`/api/account/login`,{
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
|
|
@ -769,6 +769,17 @@ class canopyAjaxUtils{
|
||||||
location.reload();
|
location.reload();
|
||||||
}else if(response.status == 429){
|
}else if(response.status == 429){
|
||||||
location = `/login?user=${user}`;
|
location = `/login?user=${user}`;
|
||||||
|
}else if(response.status == 301){
|
||||||
|
/*
|
||||||
|
* So this is gross but I don't know that theres a better way to do this
|
||||||
|
* Reloading the page would mean either sending the pass to the server as a URL query string which is insecure
|
||||||
|
* Or the server pre-loading it from the request, however sending passwords back to users seems like a bad idea too, even if it's just an echo
|
||||||
|
* Using fetch API to load the page assets in dynamically fucks up too, because register.js waits for DOM to load
|
||||||
|
*
|
||||||
|
* We could try an iframe and inject the password into that, however that seems really fucking dirty
|
||||||
|
* Sometimes it might just be better to make the user re-enter it...
|
||||||
|
*/
|
||||||
|
location = `/migrate?user=${user}`;
|
||||||
}else{
|
}else{
|
||||||
utils.ux.displayResponseError(await response.json());
|
utils.ux.displayResponseError(await response.json());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue