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;
|
||||
username : string | undefined;
|
||||
rank : number | undefined;
|
||||
developer : boolean | undefined;
|
||||
}
|
||||
|
||||
export interface SessionResult {
|
||||
|
@ -211,6 +212,7 @@ export interface SessionResult {
|
|||
username : string | undefined;
|
||||
email : string | undefined;
|
||||
rank : number | undefined;
|
||||
developer : boolean | undefined;
|
||||
}
|
||||
|
||||
export interface LogoutResult {
|
||||
|
|
|
@ -68,10 +68,14 @@ elements.adminLoginForm.addEventListener('submit', async e => {
|
|||
hcaptcha.reset(hcaptchaid);
|
||||
if (result.success) {
|
||||
if (result.rank !== 2) {
|
||||
alert("You are not an administrator!");
|
||||
if (!result.developer) {
|
||||
alert("You have no power here!");
|
||||
await auth.logout();
|
||||
return false;
|
||||
}
|
||||
elements.usersNavLink.style.display = "none";
|
||||
loadBotsView();
|
||||
} else loadUsersView();
|
||||
localStorage.setItem(`collabvm_session_${new URL(Config.APIEndpoint).host}`, result.token!);
|
||||
loadAdminView();
|
||||
} else {
|
||||
|
@ -270,7 +274,6 @@ function loadAdminView() {
|
|||
elements.adminView.style.display = "block";
|
||||
elements.navbarNav.style.display = "";
|
||||
elements.accountDropdownUsername.innerText = auth!.account!.username;
|
||||
loadUsersView();
|
||||
}
|
||||
|
||||
function loadLoginForm() {
|
||||
|
|
Loading…
Reference in a new issue