mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
avoid introspection to get available roles as admin
This commit is contained in:
parent
dabc36d1b3
commit
a5df793c55
@ -122,6 +122,7 @@ export default shield(
|
||||
MyInviteCodes: isAuthenticated,
|
||||
isValidInviteCode: allow,
|
||||
queryLocations: isAuthenticated,
|
||||
availableRoles: isAdmin,
|
||||
},
|
||||
Mutation: {
|
||||
'*': deny,
|
||||
|
||||
7
backend/src/schema/resolvers/roles.js
Normal file
7
backend/src/schema/resolvers/roles.js
Normal file
@ -0,0 +1,7 @@
|
||||
export default {
|
||||
Query: {
|
||||
availableRoles: async (_parent, args, context, _resolveInfo) => {
|
||||
return ['admin', 'moderator', 'user']
|
||||
},
|
||||
},
|
||||
}
|
||||
@ -2,4 +2,4 @@ enum UserGroup {
|
||||
admin
|
||||
moderator
|
||||
user
|
||||
}
|
||||
}
|
||||
|
||||
@ -170,6 +170,7 @@ type Query {
|
||||
filter: _UserFilter
|
||||
): [User]
|
||||
|
||||
availableRoles: [UserGroup]!
|
||||
mutedUsers: [User]
|
||||
blockedUsers: [User]
|
||||
isLoggedIn: Boolean!
|
||||
|
||||
@ -3,12 +3,7 @@ import gql from 'graphql-tag'
|
||||
export const FetchAllRoles = () => {
|
||||
return gql`
|
||||
query {
|
||||
__type(name: "UserGroup") {
|
||||
name
|
||||
enumValues {
|
||||
name
|
||||
}
|
||||
}
|
||||
availableRoles
|
||||
}
|
||||
`
|
||||
}
|
||||
|
||||
@ -178,8 +178,8 @@ export default {
|
||||
query() {
|
||||
return FetchAllRoles()
|
||||
},
|
||||
update({ __type }) {
|
||||
return __type.enumValues.map((item) => item.name)
|
||||
update({ availableRoles }) {
|
||||
return availableRoles
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user