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',
|
REDEEM_TRANSACTION_LINK = 'REDEEM_TRANSACTION_LINK',
|
||||||
LIST_TRANSACTION_LINKS = 'LIST_TRANSACTION_LINKS',
|
LIST_TRANSACTION_LINKS = 'LIST_TRANSACTION_LINKS',
|
||||||
GDT_BALANCE = 'GDT_BALANCE',
|
GDT_BALANCE = 'GDT_BALANCE',
|
||||||
|
CREATE_CONTRIBUTION = 'CREATE_CONTRIBUTION',
|
||||||
// Admin
|
// Admin
|
||||||
SEARCH_USERS = 'SEARCH_USERS',
|
SEARCH_USERS = 'SEARCH_USERS',
|
||||||
SET_USER_ROLE = 'SET_USER_ROLE',
|
SET_USER_ROLE = 'SET_USER_ROLE',
|
||||||
|
|||||||
@ -23,6 +23,7 @@ export const ROLE_USER = new Role('user', [
|
|||||||
RIGHTS.REDEEM_TRANSACTION_LINK,
|
RIGHTS.REDEEM_TRANSACTION_LINK,
|
||||||
RIGHTS.LIST_TRANSACTION_LINKS,
|
RIGHTS.LIST_TRANSACTION_LINKS,
|
||||||
RIGHTS.GDT_BALANCE,
|
RIGHTS.GDT_BALANCE,
|
||||||
|
RIGHTS.CREATE_CONTRIBUTION,
|
||||||
])
|
])
|
||||||
export const ROLE_ADMIN = new Role('admin', Object.values(RIGHTS)) // all rights
|
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 { Context, getUser } from '@/server/context'
|
||||||
import { backendLogger as logger } from '@/server/logger'
|
import { backendLogger as logger } from '@/server/logger'
|
||||||
import { Contribution } from '@entity/Contribution'
|
import { Contribution } from '@entity/Contribution'
|
||||||
@ -8,13 +9,12 @@ import { isContributionValid } from './util/isContributionValid'
|
|||||||
|
|
||||||
@Resolver()
|
@Resolver()
|
||||||
export class ContributionResolver {
|
export class ContributionResolver {
|
||||||
@Authorized([])
|
@Authorized([RIGHTS.CREATE_CONTRIBUTION])
|
||||||
@Mutation(() => Contribution)
|
@Mutation(() => Boolean)
|
||||||
async createContribution(
|
async createContribution(
|
||||||
@Args() { amount, memo, creationDate }: CreateContributionArgs,
|
@Args() { amount, memo, creationDate }: CreateContributionArgs,
|
||||||
@Ctx() context: Context,
|
@Ctx() context: Context,
|
||||||
): Promise<Contribution> {
|
): Promise<boolean> {
|
||||||
logger.trace('createContribution..')
|
|
||||||
const user = getUser(context)
|
const user = getUser(context)
|
||||||
if (!user) {
|
if (!user) {
|
||||||
throw new Error(`Could not find user`)
|
throw new Error(`Could not find user`)
|
||||||
@ -40,6 +40,6 @@ export class ContributionResolver {
|
|||||||
|
|
||||||
logger.trace('contribution to save', contribution)
|
logger.trace('contribution to save', contribution)
|
||||||
await Contribution.save(contribution)
|
await Contribution.save(contribution)
|
||||||
return contribution
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user