hide "add channel" button if the user cant create channels + public user object now shows permissions
This commit is contained in:
parent
e7615879e4
commit
e1fccd2a66
2 changed files with 16 additions and 7 deletions
|
@ -49,12 +49,14 @@
|
|||
{/if}
|
||||
</button>
|
||||
{/each}
|
||||
{#if $userInfoStore && $userInfoStore.permissions.create_channel}
|
||||
<button on:click="{ () => overlayStore.open('createChannel') }" class="sidebar-button">
|
||||
<div>
|
||||
<PlusIcon />
|
||||
</div>
|
||||
<span>Create Channel</span>
|
||||
</button>
|
||||
{/if}
|
||||
<button on:click="{ () => overlayStore.open('settings') }" class="sidebar-button">
|
||||
<div>
|
||||
<SettingsIcon />
|
||||
|
|
|
@ -2,6 +2,7 @@ import { NextFunction, Request, Response } from "express";
|
|||
import { JwtPayload, sign, verify } from "jsonwebtoken";
|
||||
import { query } from "./database";
|
||||
import { errors } from "./errors";
|
||||
import serverConfig from "./serverconfig";
|
||||
|
||||
const jwtSecret = process.env.JWT_SECRET || "[generic token]";
|
||||
|
||||
|
@ -15,8 +16,14 @@ if (jwtSecret === "[generic token]") {
|
|||
process.exit(1);
|
||||
}
|
||||
|
||||
export function getUserPermissions(user: User) {
|
||||
return {
|
||||
create_channel: serverConfig.superuserRequirement.createChannel ? user.is_superuser : true
|
||||
};
|
||||
}
|
||||
|
||||
export function getPublicUserObject(user: User) {
|
||||
const newUser = { ...user };
|
||||
const newUser = { ...user, permissions: getUserPermissions(user) };
|
||||
newUser.password = undefined;
|
||||
delete newUser.password;
|
||||
|
||||
|
|
Loading…
Reference in a new issue