mirror of
https://github.com/hrfee/jfa-go.git
synced 2024-12-28 20:10:11 +00:00
Compare commits
No commits in common. "b5dea7755b5d801528e244e11a906d64b2c6c2a2" and "a11ac1b1a30d112704977bd3fda3ef26d63b0918" have entirely different histories.
b5dea7755b
...
a11ac1b1a3
@ -159,7 +159,6 @@ func (app *appContext) loadRoutes(router *gin.Engine) {
|
|||||||
}
|
}
|
||||||
if userPageEnabled {
|
if userPageEnabled {
|
||||||
router.GET(p+"/my/account", app.MyUserPage)
|
router.GET(p+"/my/account", app.MyUserPage)
|
||||||
router.GET(p+"/my/account/password/reset", app.MyUserPage)
|
|
||||||
router.GET(p+"/my/token/login", app.getUserTokenLogin)
|
router.GET(p+"/my/token/login", app.getUserTokenLogin)
|
||||||
router.GET(p+"/my/token/refresh", app.getUserTokenRefresh)
|
router.GET(p+"/my/token/refresh", app.getUserTokenRefresh)
|
||||||
router.GET(p+"/my/confirm/:jwt", app.ConfirmMyAction)
|
router.GET(p+"/my/confirm/:jwt", app.ConfirmMyAction)
|
||||||
|
@ -2,7 +2,6 @@ import { Modal } from "../modules/modal.js";
|
|||||||
import { toggleLoader, _post } from "../modules/common.js";
|
import { toggleLoader, _post } from "../modules/common.js";
|
||||||
|
|
||||||
export class Login {
|
export class Login {
|
||||||
loggedIn: boolean = false;
|
|
||||||
private _modal: Modal;
|
private _modal: Modal;
|
||||||
private _form: HTMLFormElement;
|
private _form: HTMLFormElement;
|
||||||
private _url: string;
|
private _url: string;
|
||||||
@ -92,7 +91,6 @@ export class Login {
|
|||||||
} else {
|
} else {
|
||||||
const data = req.response;
|
const data = req.response;
|
||||||
window.token = data["token"];
|
window.token = data["token"];
|
||||||
this.loggedIn = true;
|
|
||||||
if (this._onLogin) {
|
if (this._onLogin) {
|
||||||
this._onLogin(username, password);
|
this._onLogin(username, password);
|
||||||
}
|
}
|
||||||
|
@ -20,9 +20,7 @@ export class Modal implements Modal {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
close = (event?: Event, noDispatch?: boolean) => {
|
close = (event?: Event) => {
|
||||||
// If we don't check we can mess up a closed modal.
|
|
||||||
if (!this.modal.classList.contains("block") && !this.modal.classList.contains("animate-fade-in")) return;
|
|
||||||
if (event) {
|
if (event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
}
|
}
|
||||||
@ -32,8 +30,8 @@ export class Modal implements Modal {
|
|||||||
const listenerFunc = () => {
|
const listenerFunc = () => {
|
||||||
modal.classList.remove('block');
|
modal.classList.remove('block');
|
||||||
modal.classList.remove('animate-fade-out');
|
modal.classList.remove('animate-fade-out');
|
||||||
modal.removeEventListener(window.animationEvent, listenerFunc)
|
modal.removeEventListener(window.animationEvent, listenerFunc);
|
||||||
if (!noDispatch) document.dispatchEvent(this.closeEvent);
|
document.dispatchEvent(this.closeEvent);
|
||||||
};
|
};
|
||||||
this.modal.addEventListener(window.animationEvent, listenerFunc, false);
|
this.modal.addEventListener(window.animationEvent, listenerFunc, false);
|
||||||
}
|
}
|
||||||
|
@ -525,6 +525,7 @@ const pageNames: string[][] = [];
|
|||||||
})();
|
})();
|
||||||
|
|
||||||
window.onpopstate = (event: PopStateEvent) => {
|
window.onpopstate = (event: PopStateEvent) => {
|
||||||
|
console.log("CALLLLLLLL", event);
|
||||||
if (event.state === "welcome") {
|
if (event.state === "welcome") {
|
||||||
cards[0].classList.remove("unfocused");
|
cards[0].classList.remove("unfocused");
|
||||||
for (let i = 1; i < cards.length; i++) { cards[i].classList.add("unfocused"); }
|
for (let i = 1; i < cards.length; i++) { cards[i].classList.add("unfocused"); }
|
||||||
|
@ -2,7 +2,7 @@ declare interface Modal {
|
|||||||
modal: HTMLElement;
|
modal: HTMLElement;
|
||||||
closeButton: HTMLSpanElement
|
closeButton: HTMLSpanElement
|
||||||
show: () => void;
|
show: () => void;
|
||||||
close: (event?: Event, noDispatch?: boolean) => void;
|
close: (event?: Event) => void;
|
||||||
toggle: () => void;
|
toggle: () => void;
|
||||||
onopen: (f: () => void) => void;
|
onopen: (f: () => void) => void;
|
||||||
onclose: (f: () => void) => void;
|
onclose: (f: () => void) => void;
|
||||||
|
36
ts/user.ts
36
ts/user.ts
@ -50,37 +50,19 @@ window.modals = {} as Modals;
|
|||||||
if (window.pwrEnabled) {
|
if (window.pwrEnabled) {
|
||||||
window.modals.pwr = new Modal(document.getElementById("modal-pwr"), false);
|
window.modals.pwr = new Modal(document.getElementById("modal-pwr"), false);
|
||||||
window.modals.pwr.onclose = () => {
|
window.modals.pwr.onclose = () => {
|
||||||
window.history.pushState("", "", window.location.pathname.replace("/password/reset", ""));
|
window.modals.login.show();
|
||||||
};
|
};
|
||||||
const resetButton = document.getElementById("modal-login-pwr");
|
const resetButton = document.getElementById("modal-login-pwr");
|
||||||
resetButton.onclick = () => {
|
resetButton.onclick = () => {
|
||||||
window.history.pushState("reset", "", window.location.pathname+"/password/reset");
|
const usernameInput = document.getElementById("login-user") as HTMLInputElement;
|
||||||
|
const input = document.getElementById("pwr-address") as HTMLInputElement;
|
||||||
|
input.value = usernameInput.value;
|
||||||
|
window.modals.login.close();
|
||||||
|
window.modals.pwr.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
window.onpopstate = (event: PopStateEvent) => {
|
|
||||||
if ((event.state == "reset" || window.location.pathname.includes("/password/reset")) && window.pwrEnabled) {
|
|
||||||
const usernameInput = document.getElementById("login-user") as HTMLInputElement;
|
|
||||||
const input = document.getElementById("pwr-address") as HTMLInputElement;
|
|
||||||
input.value = usernameInput.value;
|
|
||||||
window.modals.login.close();
|
|
||||||
window.modals.pwr.show();
|
|
||||||
} else {
|
|
||||||
window.modals.pwr.close(null, true);
|
|
||||||
if (!login.loggedIn) login.login("", "");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|
||||||
(() => {
|
|
||||||
const pushState = window.history.pushState;
|
|
||||||
window.history.pushState = function (data: any, __: string, _: string | URL) {
|
|
||||||
pushState.apply(window.history, arguments);
|
|
||||||
let ev = { state: data as string } as PopStateEvent;
|
|
||||||
window.onpopstate(ev);
|
|
||||||
};
|
|
||||||
})();
|
|
||||||
|
|
||||||
window.notifications = new notificationBox(document.getElementById('notification-box') as HTMLDivElement, 5);
|
window.notifications = new notificationBox(document.getElementById('notification-box') as HTMLDivElement, 5);
|
||||||
|
|
||||||
if (window.pwrEnabled && window.linkResetEnabled) {
|
if (window.pwrEnabled && window.linkResetEnabled) {
|
||||||
@ -798,8 +780,4 @@ const generatePermutations = (xs: number[]): [number[], number[]][] => {
|
|||||||
|
|
||||||
login.bindLogout(document.getElementById("logout-button"));
|
login.bindLogout(document.getElementById("logout-button"));
|
||||||
|
|
||||||
(() => {
|
login.login("", "");
|
||||||
let data = "";
|
|
||||||
if (window.location.pathname.endsWith("/password/reset")) data = "reset";
|
|
||||||
window.history.pushState(data, "", window.location.pathname);
|
|
||||||
})();
|
|
||||||
|
Loading…
Reference in New Issue
Block a user