Skip to content

Commit

Permalink
Refactor login logic and update page permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
Schlauer-Hax committed Mar 14, 2024
1 parent a126c6b commit b862f45
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion components/nav.ts
Expand Up @@ -16,7 +16,7 @@ const navMenuPopover = Popover(
Box(
activeUser.$permission.map(() => Vertical(
Label("SWITCH TO").addClass("title"),
pages.map(([ logo, permission, route, login ]) => permCheck(...permission) && ((login && activeUser.id) || !login)
pages.map(([ logo, permission, route, login ]) => permCheck(...permission) && (!login || (login == 1 && IsLoggedIn()) || (login == 2 && !IsLoggedIn()))
? Horizontal(
Image(logo, "Logo"),
Spacer(),
Expand Down
14 changes: 8 additions & 6 deletions components/pages.ts
Expand Up @@ -11,12 +11,14 @@ import bbnWalletLogo from '../assets/img/bbnWallet.svg';

import { Permission } from "shared/mod.ts";

export const pages: [ logo: string, perm: Array<Permission>, route: string, login: boolean ][] = [
[ bbnHolding, [], "/", false ],
[ bbnMusicLogo, [], "/music", false ],
[ bbnHostingLogo, [], "/hosting", false ],
[ bbnWalletLogo, [], "/wallet", true ],
[ bbnAdminLogo, [ "/bbn/manage", "/hmsys/user" ], "/admin", true ],
// 0: no login required, 1: show only when logged in, 2: show only when logged out
export const pages: [ logo: string, perm: Array<Permission>, route: string, login: 0|1|2 ][] = [
[ bbnHolding, [], "/", 0 ],
[ bbnMusicLogo, [], "/c/music", 1 ],
[ bbnMusicLogo, [], "/music", 2 ],
[ bbnHostingLogo, [], "/hosting", 0 ],
[ bbnWalletLogo, [], "/wallet", 1 ],
[ bbnAdminLogo, [ "/bbn/manage", "/hmsys/user" ], "/admin", 1 ],
];

// Moved this to the up array when we use the hmsys permission system
Expand Down

0 comments on commit b862f45

Please sign in to comment.