add support for non-admin developer status
This commit is contained in:
parent
2e6bc45977
commit
61de380588
2 changed files with 10 additions and 5 deletions
|
@ -202,6 +202,7 @@ export interface AccountLoginResult {
|
||||||
email : string | undefined;
|
email : string | undefined;
|
||||||
username : string | undefined;
|
username : string | undefined;
|
||||||
rank : number | undefined;
|
rank : number | undefined;
|
||||||
|
developer : boolean | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SessionResult {
|
export interface SessionResult {
|
||||||
|
@ -211,6 +212,7 @@ export interface SessionResult {
|
||||||
username : string | undefined;
|
username : string | undefined;
|
||||||
email : string | undefined;
|
email : string | undefined;
|
||||||
rank : number | undefined;
|
rank : number | undefined;
|
||||||
|
developer : boolean | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface LogoutResult {
|
export interface LogoutResult {
|
||||||
|
|
|
@ -68,10 +68,14 @@ elements.adminLoginForm.addEventListener('submit', async e => {
|
||||||
hcaptcha.reset(hcaptchaid);
|
hcaptcha.reset(hcaptchaid);
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
if (result.rank !== 2) {
|
if (result.rank !== 2) {
|
||||||
alert("You are not an administrator!");
|
if (!result.developer) {
|
||||||
await auth.logout();
|
alert("You have no power here!");
|
||||||
return false;
|
await auth.logout();
|
||||||
}
|
return false;
|
||||||
|
}
|
||||||
|
elements.usersNavLink.style.display = "none";
|
||||||
|
loadBotsView();
|
||||||
|
} else loadUsersView();
|
||||||
localStorage.setItem(`collabvm_session_${new URL(Config.APIEndpoint).host}`, result.token!);
|
localStorage.setItem(`collabvm_session_${new URL(Config.APIEndpoint).host}`, result.token!);
|
||||||
loadAdminView();
|
loadAdminView();
|
||||||
} else {
|
} else {
|
||||||
|
@ -270,7 +274,6 @@ function loadAdminView() {
|
||||||
elements.adminView.style.display = "block";
|
elements.adminView.style.display = "block";
|
||||||
elements.navbarNav.style.display = "";
|
elements.navbarNav.style.display = "";
|
||||||
elements.accountDropdownUsername.innerText = auth!.account!.username;
|
elements.accountDropdownUsername.innerText = auth!.account!.username;
|
||||||
loadUsersView();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadLoginForm() {
|
function loadLoginForm() {
|
||||||
|
|
Loading…
Reference in a new issue