File tree 1 file changed +29
-0
lines changed
1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Authentication
2
+
3
+ Authentication can be used as a guard on a field, query or mutation, restricting data access or actions for a specific group of users.
4
+
5
+ Since the codebase uses TypeGraphQL, which relies heavily on decorators, authentication is also done using decorators.
6
+
7
+ Authentication is done with use of ` @Permission ` decorator. This decorator takes function as an argument with permission object as a return value.
8
+
9
+ For example:
10
+
11
+ ``` lang=js
12
+ @Permission(({ args }) =>
13
+ Promise.resolve({
14
+ or: [
15
+ { type: 'global', permission: P.global.VIEW_ANY_PLAN_DATA },
16
+ { type: 'plan', permission: P.plan.VIEW_DATA, id: args.id },
17
+ ],
18
+ })
19
+ )
20
+ ```
21
+
22
+ If only global permission check is needed, it can be used directly:
23
+
24
+ ``` lang=js
25
+ @Permission({
26
+ type: 'global',
27
+ permission: P.global.VIEW_ALL_JOBS,
28
+ })
29
+ ```
You can’t perform that action at this time.
0 commit comments