Migration UI complete.

This commit is contained in:
rainbow napkin 2025-10-16 21:22:37 -04:00
parent eb48b92551
commit 6bab5b4723
9 changed files with 45 additions and 14 deletions

View file

@ -18,6 +18,7 @@ class registerPrompt{
constructor(){
//Grab user prompt
this.user = document.querySelector("#login-page-username");
this.user.value = window.location.search.replace("?user=",'');
//Grab pass prompts
this.pass = document.querySelector("#login-page-password");
//Grab register button

View file

@ -18,6 +18,7 @@ class migratePrompt{
constructor(){
//Grab user prompt
this.user = document.querySelector("#migrate-username");
this.user.value = window.location.search.replace("?user=",'');
//Grab pass prompts
this.oldPass = document.querySelector("#migrate-password-old");
this.pass = document.querySelector("#migrate-password");
@ -37,6 +38,8 @@ class migratePrompt{
//Add verification event listener to altcha widget
this.altcha.addEventListener("verified", this.verify.bind(this));
console.log(this.button);
//Add migrate event listener to migrate button
this.button.addEventListener("click", this.migrate.bind(this));
}

View file

@ -756,7 +756,7 @@ class canopyAjaxUtils{
}
async login(user, pass, verification){
var response = await fetch(`/api/account/login`,{
const response = await fetch(`/api/account/login`,{
method: "POST",
headers: {
"Content-Type": "application/json",
@ -769,6 +769,17 @@ class canopyAjaxUtils{
location.reload();
}else if(response.status == 429){
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{
utils.ux.displayResponseError(await response.json());
}