Browse Source

feat: Better role resolution in stream keys

develop
Dale 3 weeks ago
parent
commit
5ffe8e9f42
Signed by: Deiru GPG Key ID: AA250C0277B927E1
2 changed files with 6 additions and 2 deletions
  1. +1
    -1
      src/db/generate-roles.ts
  2. +5
    -1
      src/graphql/resolvers/stream-keys/index.ts

+ 1
- 1
src/db/generate-roles.ts View File

@ -63,7 +63,7 @@ const defaultUserRole: Role = {
rights: {
streamKeys: AccessUnit.Self,
channels: AccessUnit.Self,
users: AccessUnit.Read,
users: AccessUnit.Self,
activities: AccessUnit.Read,
},
actions: {


+ 5
- 1
src/graphql/resolvers/stream-keys/index.ts View File

@ -20,7 +20,11 @@ export const streamKeysQueryResolver: QueryResolvers<ResolverContext>["streamKey
export const selfStreamKeysQueryResolver: QueryResolvers<ResolverContext>["selfStreamKeys"] =
async (_, _args, { user, userRoles, db: { streamKeys } }) => {
if (checkRight(userRoles, AccessUnit.Self, "streamKeys")) {
if (
checkRight(userRoles, AccessUnit.Self, "streamKeys") ||
checkRight(userRoles, AccessUnit.Write, "streamKeys") ||
checkRight(userRoles, AccessUnit.Read, "streamKeys")
) {
return streamKeys.getStreamKeys({ userId: user.id });
}
throw new AuthorizationError();


Loading…
Cancel
Save