fix, add auto login when register

This commit is contained in:
2023-12-04 12:32:15 +01:00
parent 25f315c24f
commit 910644a804
6 changed files with 29 additions and 11 deletions

View File

@ -1,3 +1,4 @@
import { client } from "../index.js";
import AbstractAuthentificateView from "./AbstractAuthentifiedView.js";
export default class extends AbstractAuthentificateView {

View File

@ -20,6 +20,11 @@ export default class extends AbstractAuthentificateView
{
let data = await client.account.get();
if (data === null)
{
navigateTo("/login")
return;
}
document.getElementById("username").value = data.username;
}
@ -63,12 +68,17 @@ export default class extends AbstractAuthentificateView
if (new_password.length != 0)
data.new_password = new_password;
let response_data = await client.account.update(data, current_password);
if (response_data === null)
{
navigateTo(super.redirect_url);
navigateTo("/login");
return;
}
else if (response_data === "data has been alterate")
{
navigateTo("/me");
return;
}
["username", "new_password", "current_password"].forEach(error_field => {
let error_display = document.getElementById(`error_${error_field}`);

View File

@ -1,5 +1,5 @@
import { client, navigateTo } from "../../index.js";
import AbstractAuthentifiedView from "../AbstractNonAuthentified.js";
import AbstractNonAuthentifiedView from "../AbstractNonAuthentified.js";
async function register()
{
@ -14,7 +14,6 @@ async function register()
return;
}
["username", "user", "password"].forEach(error_field => {
let error_display = document.getElementById(`error_${error_field}`);
if (error_display != null)
@ -28,7 +27,7 @@ async function register()
});
}
export default class extends AbstractAuthentifiedView {
export default class extends AbstractNonAuthentifiedView {
constructor(params) {
super(params, "Register", "/home");
}