mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
Change response value to boolean, add RIGHTS for createContribution, add new RIGHT in ROLES.
This commit is contained in:
parent
6ac0106470
commit
c03509c525
@ -25,6 +25,7 @@ export enum RIGHTS {
|
||||
REDEEM_TRANSACTION_LINK = 'REDEEM_TRANSACTION_LINK',
|
||||
LIST_TRANSACTION_LINKS = 'LIST_TRANSACTION_LINKS',
|
||||
GDT_BALANCE = 'GDT_BALANCE',
|
||||
CREATE_CONTRIBUTION = 'CREATE_CONTRIBUTION',
|
||||
// Admin
|
||||
SEARCH_USERS = 'SEARCH_USERS',
|
||||
SET_USER_ROLE = 'SET_USER_ROLE',
|
||||
|
||||
@ -23,6 +23,7 @@ export const ROLE_USER = new Role('user', [
|
||||
RIGHTS.REDEEM_TRANSACTION_LINK,
|
||||
RIGHTS.LIST_TRANSACTION_LINKS,
|
||||
RIGHTS.GDT_BALANCE,
|
||||
RIGHTS.CREATE_CONTRIBUTION,
|
||||
])
|
||||
export const ROLE_ADMIN = new Role('admin', Object.values(RIGHTS)) // all rights
|
||||
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import { RIGHTS } from '@/auth/RIGHTS'
|
||||
import { Context, getUser } from '@/server/context'
|
||||
import { backendLogger as logger } from '@/server/logger'
|
||||
import { Contribution } from '@entity/Contribution'
|
||||
@ -8,13 +9,12 @@ import { isContributionValid } from './util/isContributionValid'
|
||||
|
||||
@Resolver()
|
||||
export class ContributionResolver {
|
||||
@Authorized([])
|
||||
@Mutation(() => Contribution)
|
||||
@Authorized([RIGHTS.CREATE_CONTRIBUTION])
|
||||
@Mutation(() => Boolean)
|
||||
async createContribution(
|
||||
@Args() { amount, memo, creationDate }: CreateContributionArgs,
|
||||
@Ctx() context: Context,
|
||||
): Promise<Contribution> {
|
||||
logger.trace('createContribution..')
|
||||
): Promise<boolean> {
|
||||
const user = getUser(context)
|
||||
if (!user) {
|
||||
throw new Error(`Could not find user`)
|
||||
@ -40,6 +40,6 @@ export class ContributionResolver {
|
||||
|
||||
logger.trace('contribution to save', contribution)
|
||||
await Contribution.save(contribution)
|
||||
return contribution
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user