@lenne.tech/nest-server 10.3.1 → 10.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/common/inputs/combined-filter.input.js +5 -0
- package/dist/core/common/inputs/combined-filter.input.js.map +1 -1
- package/dist/core/common/inputs/filter.input.js +5 -0
- package/dist/core/common/inputs/filter.input.js.map +1 -1
- package/dist/core/common/inputs/single-filter.input.js +10 -0
- package/dist/core/common/inputs/single-filter.input.js.map +1 -1
- package/dist/core/common/inputs/sort.input.js +5 -0
- package/dist/core/common/inputs/sort.input.js.map +1 -1
- package/dist/core/common/models/core-persistence.model.js +1 -0
- package/dist/core/common/models/core-persistence.model.js.map +1 -1
- package/dist/core/modules/auth/core-auth.controller.js +7 -0
- package/dist/core/modules/auth/core-auth.controller.js.map +1 -1
- package/dist/core/modules/auth/core-auth.model.js +6 -0
- package/dist/core/modules/auth/core-auth.model.js.map +1 -1
- package/dist/core/modules/auth/core-auth.resolver.js +7 -0
- package/dist/core/modules/auth/core-auth.resolver.js.map +1 -1
- package/dist/core/modules/auth/inputs/core-auth-sign-in.input.js +7 -0
- package/dist/core/modules/auth/inputs/core-auth-sign-in.input.js.map +1 -1
- package/dist/core/modules/auth/inputs/core-auth-sign-up.input.js +3 -0
- package/dist/core/modules/auth/inputs/core-auth-sign-up.input.js.map +1 -1
- package/dist/core/modules/file/core-file-info.model.js +14 -0
- package/dist/core/modules/file/core-file-info.model.js.map +1 -1
- package/dist/core/modules/file/core-file.controller.js +4 -0
- package/dist/core/modules/file/core-file.controller.js.map +1 -1
- package/dist/core/modules/file/core-file.resolver.js +7 -0
- package/dist/core/modules/file/core-file.resolver.js.map +1 -1
- package/dist/core/modules/health-check/core-health-check-result.model.js +7 -0
- package/dist/core/modules/health-check/core-health-check-result.model.js.map +1 -1
- package/dist/core/modules/health-check/core-health-check.controller.js +4 -0
- package/dist/core/modules/health-check/core-health-check.controller.js.map +1 -1
- package/dist/core/modules/user/core-user.model.js +15 -0
- package/dist/core/modules/user/core-user.model.js.map +1 -1
- package/dist/core/modules/user/inputs/core-user-create.input.js +4 -0
- package/dist/core/modules/user/inputs/core-user-create.input.js.map +1 -1
- package/dist/core/modules/user/inputs/core-user.input.js +6 -0
- package/dist/core/modules/user/inputs/core-user.input.js.map +1 -1
- package/dist/server/common/models/persistence.model.js +5 -0
- package/dist/server/common/models/persistence.model.js.map +1 -1
- package/dist/server/modules/auth/auth.controller.js +3 -0
- package/dist/server/modules/auth/auth.controller.js.map +1 -1
- package/dist/server/modules/auth/auth.model.js +4 -0
- package/dist/server/modules/auth/auth.model.js.map +1 -1
- package/dist/server/modules/auth/auth.resolver.js +5 -0
- package/dist/server/modules/auth/auth.resolver.js.map +1 -1
- package/dist/server/modules/auth/inputs/auth-sign-in.input.js +3 -0
- package/dist/server/modules/auth/inputs/auth-sign-in.input.js.map +1 -1
- package/dist/server/modules/auth/inputs/auth-sign-up.input.js +5 -0
- package/dist/server/modules/auth/inputs/auth-sign-up.input.js.map +1 -1
- package/dist/server/modules/file/file-info.model.js +3 -0
- package/dist/server/modules/file/file-info.model.js.map +1 -1
- package/dist/server/modules/file/file.controller.js +4 -0
- package/dist/server/modules/file/file.controller.js.map +1 -1
- package/dist/server/modules/user/avatar.controller.js +1 -0
- package/dist/server/modules/user/avatar.controller.js.map +1 -1
- package/dist/server/modules/user/inputs/user-create.input.js +3 -0
- package/dist/server/modules/user/inputs/user-create.input.js.map +1 -1
- package/dist/server/modules/user/inputs/user.input.js +3 -0
- package/dist/server/modules/user/inputs/user.input.js.map +1 -1
- package/dist/server/modules/user/outputs/find-and-count-users-result.output.js +5 -0
- package/dist/server/modules/user/outputs/find-and-count-users-result.output.js.map +1 -1
- package/dist/server/modules/user/user.model.d.ts +1 -0
- package/dist/server/modules/user/user.model.js +14 -0
- package/dist/server/modules/user/user.model.js.map +1 -1
- package/dist/server/server.controller.js +2 -0
- package/dist/server/server.controller.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/core/common/inputs/combined-filter.input.ts +5 -0
- package/src/core/common/inputs/filter.input.ts +5 -0
- package/src/core/common/inputs/single-filter.input.ts +10 -0
- package/src/core/common/inputs/sort.input.ts +5 -0
- package/src/core/common/models/core-persistence.model.ts +1 -0
- package/src/core/modules/auth/core-auth.controller.ts +7 -0
- package/src/core/modules/auth/core-auth.model.ts +6 -0
- package/src/core/modules/auth/core-auth.resolver.ts +7 -0
- package/src/core/modules/auth/inputs/core-auth-sign-in.input.ts +7 -0
- package/src/core/modules/auth/inputs/core-auth-sign-up.input.ts +3 -0
- package/src/core/modules/file/core-file-info.model.ts +10 -0
- package/src/core/modules/file/core-file.controller.ts +4 -0
- package/src/core/modules/file/core-file.resolver.ts +7 -0
- package/src/core/modules/health-check/core-health-check-result.model.ts +7 -0
- package/src/core/modules/health-check/core-health-check.controller.ts +4 -0
- package/src/core/modules/user/core-user.model.ts +15 -0
- package/src/core/modules/user/inputs/core-user-create.input.ts +4 -0
- package/src/core/modules/user/inputs/core-user.input.ts +6 -0
- package/src/server/common/models/persistence.model.ts +5 -0
- package/src/server/modules/auth/auth.controller.ts +3 -0
- package/src/server/modules/auth/auth.model.ts +4 -0
- package/src/server/modules/auth/auth.resolver.ts +5 -0
- package/src/server/modules/auth/inputs/auth-sign-in.input.ts +3 -0
- package/src/server/modules/auth/inputs/auth-sign-up.input.ts +5 -0
- package/src/server/modules/file/file-info.model.ts +3 -0
- package/src/server/modules/file/file.controller.ts +4 -0
- package/src/server/modules/user/avatar.controller.ts +1 -0
- package/src/server/modules/user/inputs/user-create.input.ts +3 -0
- package/src/server/modules/user/inputs/user.input.ts +3 -0
- package/src/server/modules/user/outputs/find-and-count-users-result.output.ts +5 -0
- package/src/server/modules/user/user.model.ts +15 -0
- package/src/server/server.controller.ts +2 -0
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Field, InputType } from '@nestjs/graphql';
|
|
2
2
|
import { IsEmail } from 'class-validator';
|
|
3
3
|
|
|
4
|
+
import { Restricted } from '../../../common/decorators/restricted.decorator';
|
|
5
|
+
import { RoleEnum } from '../../../common/enums/role.enum';
|
|
4
6
|
import { CoreUserInput } from './core-user.input';
|
|
5
7
|
|
|
6
8
|
/**
|
|
@@ -10,8 +12,10 @@ import { CoreUserInput } from './core-user.input';
|
|
|
10
12
|
* otherwise the property will not be recognized via Object.keys (this is necessary for mapping) or will be initialized
|
|
11
13
|
* with a default value that may overwrite an existing value in the DB.
|
|
12
14
|
*/
|
|
15
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
13
16
|
@InputType({ description: 'User input to create a new user', isAbstract: true })
|
|
14
17
|
export abstract class CoreUserCreateInput extends CoreUserInput {
|
|
18
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
15
19
|
@Field({ description: 'Email of the user', nullable: false })
|
|
16
20
|
@IsEmail()
|
|
17
21
|
override email: string = undefined;
|
|
@@ -13,11 +13,13 @@ import { CoreInput } from '../../../common/inputs/core-input.input';
|
|
|
13
13
|
* otherwise the property will not be recognized via Object.keys (this is necessary for mapping) or will be initialized
|
|
14
14
|
* with a default value that may overwrite an existing value in the DB.
|
|
15
15
|
*/
|
|
16
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
16
17
|
@InputType({ description: 'User input', isAbstract: true })
|
|
17
18
|
export abstract class CoreUserInput extends CoreInput {
|
|
18
19
|
/**
|
|
19
20
|
* Email of the user
|
|
20
21
|
*/
|
|
22
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
21
23
|
@Field({ description: 'Email of the user', nullable: true })
|
|
22
24
|
@IsOptional()
|
|
23
25
|
@IsEmail()
|
|
@@ -26,6 +28,7 @@ export abstract class CoreUserInput extends CoreInput {
|
|
|
26
28
|
/**
|
|
27
29
|
* First name of the user
|
|
28
30
|
*/
|
|
31
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
29
32
|
@Field({ description: 'First name of the user', nullable: true })
|
|
30
33
|
@IsOptional()
|
|
31
34
|
firstName?: string = undefined;
|
|
@@ -33,6 +36,7 @@ export abstract class CoreUserInput extends CoreInput {
|
|
|
33
36
|
/**
|
|
34
37
|
* Last name of the user
|
|
35
38
|
*/
|
|
39
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
36
40
|
@Field({ description: 'Last name of the user', nullable: true })
|
|
37
41
|
@IsOptional()
|
|
38
42
|
lastName?: string = undefined;
|
|
@@ -48,6 +52,7 @@ export abstract class CoreUserInput extends CoreInput {
|
|
|
48
52
|
/**
|
|
49
53
|
* Username / alias of the user
|
|
50
54
|
*/
|
|
55
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
51
56
|
@Field({ description: 'Username / alias of the user', nullable: true })
|
|
52
57
|
@IsOptional()
|
|
53
58
|
username?: string = undefined;
|
|
@@ -55,6 +60,7 @@ export abstract class CoreUserInput extends CoreInput {
|
|
|
55
60
|
/**
|
|
56
61
|
* Password of the user
|
|
57
62
|
*/
|
|
63
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
58
64
|
@Field({ description: 'Password of the user', nullable: true })
|
|
59
65
|
@IsOptional()
|
|
60
66
|
password?: string = undefined;
|
|
@@ -2,6 +2,8 @@ import { Field, ObjectType } from '@nestjs/graphql';
|
|
|
2
2
|
import { Prop } from '@nestjs/mongoose';
|
|
3
3
|
import { Types } from 'mongoose';
|
|
4
4
|
|
|
5
|
+
import { Restricted } from '../../../core/common/decorators/restricted.decorator';
|
|
6
|
+
import { RoleEnum } from '../../../core/common/enums/role.enum';
|
|
5
7
|
import { CorePersistenceModel } from '../../../core/common/models/core-persistence.model';
|
|
6
8
|
import { User } from '../../modules/user/user.model';
|
|
7
9
|
|
|
@@ -12,6 +14,7 @@ import mongoose = require('mongoose');
|
|
|
12
14
|
*
|
|
13
15
|
* The models are a combination of MikroORM Entities and TypeGraphQL Types
|
|
14
16
|
*/
|
|
17
|
+
@Restricted(RoleEnum.ADMIN)
|
|
15
18
|
@ObjectType({
|
|
16
19
|
description: 'Persistence model which will be saved in DB',
|
|
17
20
|
isAbstract: true,
|
|
@@ -26,6 +29,7 @@ export abstract class PersistenceModel extends CorePersistenceModel {
|
|
|
26
29
|
*
|
|
27
30
|
* Not set when created by system
|
|
28
31
|
*/
|
|
32
|
+
@Restricted(RoleEnum.ADMIN)
|
|
29
33
|
@Field(() => User, {
|
|
30
34
|
description: 'ID of the user who created the object',
|
|
31
35
|
nullable: true,
|
|
@@ -38,6 +42,7 @@ export abstract class PersistenceModel extends CorePersistenceModel {
|
|
|
38
42
|
*
|
|
39
43
|
* Not set when updated by system
|
|
40
44
|
*/
|
|
45
|
+
@Restricted(RoleEnum.ADMIN)
|
|
41
46
|
@Field(() => User, {
|
|
42
47
|
description: 'ID of the user who updated the object',
|
|
43
48
|
nullable: true,
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { Controller } from '@nestjs/common';
|
|
2
2
|
|
|
3
|
+
import { Roles } from '../../../core/common/decorators/roles.decorator';
|
|
4
|
+
import { RoleEnum } from '../../../core/common/enums/role.enum';
|
|
3
5
|
import { ConfigService } from '../../../core/common/services/config.service';
|
|
4
6
|
import { CoreAuthController } from '../../../core/modules/auth/core-auth.controller';
|
|
5
7
|
import { AuthService } from './auth.service';
|
|
6
8
|
|
|
9
|
+
@Roles(RoleEnum.ADMIN)
|
|
7
10
|
@Controller('auth')
|
|
8
11
|
export class AuthController extends CoreAuthController {
|
|
9
12
|
/**
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Field, ObjectType } from '@nestjs/graphql';
|
|
2
2
|
|
|
3
|
+
import { Restricted } from '../../../core/common/decorators/restricted.decorator';
|
|
4
|
+
import { RoleEnum } from '../../../core/common/enums/role.enum';
|
|
3
5
|
import { mapClasses } from '../../../core/common/helpers/model.helper';
|
|
4
6
|
import { CoreAuthModel } from '../../../core/modules/auth/core-auth.model';
|
|
5
7
|
import { User } from '../user/user.model';
|
|
@@ -7,6 +9,7 @@ import { User } from '../user/user.model';
|
|
|
7
9
|
/**
|
|
8
10
|
* Authentication data
|
|
9
11
|
*/
|
|
12
|
+
@Restricted(RoleEnum.ADMIN)
|
|
10
13
|
@ObjectType({ description: 'Authentication data' })
|
|
11
14
|
export class Auth extends CoreAuthModel {
|
|
12
15
|
// ===================================================================================================================
|
|
@@ -16,6 +19,7 @@ export class Auth extends CoreAuthModel {
|
|
|
16
19
|
/**
|
|
17
20
|
* Signed-in user
|
|
18
21
|
*/
|
|
22
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
19
23
|
@Field(() => User, { description: 'User who signed in' })
|
|
20
24
|
override user: User = undefined;
|
|
21
25
|
|
|
@@ -2,6 +2,8 @@ import { Args, Context, Mutation, Resolver } from '@nestjs/graphql';
|
|
|
2
2
|
import { Response as ResponseType } from 'express';
|
|
3
3
|
|
|
4
4
|
import { GraphQLServiceOptions } from '../../../core/common/decorators/graphql-service-options.decorator';
|
|
5
|
+
import { Roles } from '../../../core/common/decorators/roles.decorator';
|
|
6
|
+
import { RoleEnum } from '../../../core/common/enums/role.enum';
|
|
5
7
|
import { ServiceOptions } from '../../../core/common/interfaces/service-options.interface';
|
|
6
8
|
import { ConfigService } from '../../../core/common/services/config.service';
|
|
7
9
|
import { CoreAuthResolver } from '../../../core/modules/auth/core-auth.resolver';
|
|
@@ -13,6 +15,7 @@ import { AuthSignUpInput } from './inputs/auth-sign-up.input';
|
|
|
13
15
|
/**
|
|
14
16
|
* Authentication resolver for the sign in
|
|
15
17
|
*/
|
|
18
|
+
@Roles(RoleEnum.ADMIN)
|
|
16
19
|
@Resolver(() => Auth)
|
|
17
20
|
export class AuthResolver extends CoreAuthResolver {
|
|
18
21
|
/**
|
|
@@ -28,6 +31,7 @@ export class AuthResolver extends CoreAuthResolver {
|
|
|
28
31
|
/**
|
|
29
32
|
* SignIn for User
|
|
30
33
|
*/
|
|
34
|
+
@Roles(RoleEnum.S_EVERYONE)
|
|
31
35
|
@Mutation(() => Auth, { description: 'Sign in and get JWT token' })
|
|
32
36
|
override async signIn(
|
|
33
37
|
@GraphQLServiceOptions({ gqlPath: 'signIn.user' }) serviceOptions: ServiceOptions,
|
|
@@ -44,6 +48,7 @@ export class AuthResolver extends CoreAuthResolver {
|
|
|
44
48
|
/**
|
|
45
49
|
* Sign up for user
|
|
46
50
|
*/
|
|
51
|
+
@Roles(RoleEnum.S_EVERYONE)
|
|
47
52
|
@Mutation(() => Auth, {
|
|
48
53
|
description: 'Sign up user and get JWT token',
|
|
49
54
|
})
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { InputType } from '@nestjs/graphql';
|
|
2
2
|
|
|
3
|
+
import { Restricted } from '../../../../core/common/decorators/restricted.decorator';
|
|
4
|
+
import { RoleEnum } from '../../../../core/common/enums/role.enum';
|
|
3
5
|
import { CoreAuthSignInInput } from '../../../../core/modules/auth/inputs/core-auth-sign-in.input';
|
|
4
6
|
|
|
5
7
|
/**
|
|
6
8
|
* SignIn input
|
|
7
9
|
*/
|
|
10
|
+
@Restricted(RoleEnum.ADMIN)
|
|
8
11
|
@InputType({ description: 'Sign-in input' })
|
|
9
12
|
export class AuthSignInInput extends CoreAuthSignInInput {
|
|
10
13
|
// Extend UserInput here
|
|
@@ -1,19 +1,24 @@
|
|
|
1
1
|
import { Field, InputType } from '@nestjs/graphql';
|
|
2
2
|
|
|
3
|
+
import { Restricted } from '../../../../core/common/decorators/restricted.decorator';
|
|
4
|
+
import { RoleEnum } from '../../../../core/common/enums/role.enum';
|
|
3
5
|
import { CoreAuthSignUpInput } from '../../../../core/modules/auth/inputs/core-auth-sign-up.input';
|
|
4
6
|
|
|
5
7
|
/**
|
|
6
8
|
* SignUp input
|
|
7
9
|
*/
|
|
10
|
+
@Restricted(RoleEnum.ADMIN)
|
|
8
11
|
@InputType({ description: 'Sign-up input' })
|
|
9
12
|
export class AuthSignUpInput extends CoreAuthSignUpInput {
|
|
10
13
|
// ===================================================================================================================
|
|
11
14
|
// Properties
|
|
12
15
|
// ===================================================================================================================
|
|
13
16
|
|
|
17
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
14
18
|
@Field({ description: 'firstName', nullable: true })
|
|
15
19
|
firstName: string = undefined;
|
|
16
20
|
|
|
21
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
17
22
|
@Field({ description: 'lastName', nullable: true })
|
|
18
23
|
lastName: string = undefined;
|
|
19
24
|
}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { ObjectType } from '@nestjs/graphql';
|
|
2
2
|
import { Schema as MongooseSchema, SchemaFactory } from '@nestjs/mongoose';
|
|
3
3
|
|
|
4
|
+
import { Restricted } from '../../../core/common/decorators/restricted.decorator';
|
|
5
|
+
import { RoleEnum } from '../../../core/common/enums/role.enum';
|
|
4
6
|
import { CoreFileInfo } from '../../../core/modules/file/core-file-info.model';
|
|
5
7
|
|
|
6
8
|
/**
|
|
7
9
|
* File info model
|
|
8
10
|
*/
|
|
11
|
+
@Restricted(RoleEnum.ADMIN)
|
|
9
12
|
@ObjectType({ description: 'Information about file' })
|
|
10
13
|
@MongooseSchema({ collection: 'fs.files' })
|
|
11
14
|
export class FileInfo extends CoreFileInfo {}
|
|
@@ -30,6 +30,7 @@ export class FileController {
|
|
|
30
30
|
/**
|
|
31
31
|
* Upload file
|
|
32
32
|
*/
|
|
33
|
+
@Roles(RoleEnum.ADMIN)
|
|
33
34
|
@Post('upload')
|
|
34
35
|
@UseInterceptors(FileInterceptor('file'))
|
|
35
36
|
uploadFile(@UploadedFile() file: Express.Multer.File): any {
|
|
@@ -39,6 +40,7 @@ export class FileController {
|
|
|
39
40
|
/**
|
|
40
41
|
* Download file
|
|
41
42
|
*/
|
|
43
|
+
@Roles(RoleEnum.ADMIN)
|
|
42
44
|
@Get(':id')
|
|
43
45
|
async getFile(@Param('id') id: string, @Res() res) {
|
|
44
46
|
if (!id) {
|
|
@@ -65,6 +67,7 @@ export class FileController {
|
|
|
65
67
|
/**
|
|
66
68
|
* Get file information
|
|
67
69
|
*/
|
|
70
|
+
@Roles(RoleEnum.ADMIN)
|
|
68
71
|
@Get('info/:id')
|
|
69
72
|
async getFileInfo(@Param('id') id: string) {
|
|
70
73
|
return await this.fileService.getFileInfo(id);
|
|
@@ -73,6 +76,7 @@ export class FileController {
|
|
|
73
76
|
/**
|
|
74
77
|
* Delete file
|
|
75
78
|
*/
|
|
79
|
+
@Roles(RoleEnum.ADMIN)
|
|
76
80
|
@Delete(':id')
|
|
77
81
|
async deleteFile(@Param('id') id: string) {
|
|
78
82
|
if (!id) {
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { InputType } from '@nestjs/graphql';
|
|
2
2
|
|
|
3
|
+
import { Restricted } from '../../../../core/common/decorators/restricted.decorator';
|
|
4
|
+
import { RoleEnum } from '../../../../core/common/enums/role.enum';
|
|
3
5
|
import { CoreUserCreateInput } from '../../../../core/modules/user/inputs/core-user-create.input';
|
|
4
6
|
|
|
5
7
|
/**
|
|
6
8
|
* User input to create a new user
|
|
7
9
|
*/
|
|
10
|
+
@Restricted(RoleEnum.ADMIN)
|
|
8
11
|
@InputType({ description: 'User input to create a new user' })
|
|
9
12
|
export class UserCreateInput extends CoreUserCreateInput {
|
|
10
13
|
// Extend UserCreateInput here
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { InputType } from '@nestjs/graphql';
|
|
2
2
|
|
|
3
|
+
import { Restricted } from '../../../../core/common/decorators/restricted.decorator';
|
|
4
|
+
import { RoleEnum } from '../../../../core/common/enums/role.enum';
|
|
3
5
|
import { CoreUserInput } from '../../../../core/modules/user/inputs/core-user.input';
|
|
4
6
|
|
|
5
7
|
/**
|
|
6
8
|
* User input to update a user
|
|
7
9
|
*/
|
|
10
|
+
@Restricted(RoleEnum.ADMIN)
|
|
8
11
|
@InputType({ description: 'User input' })
|
|
9
12
|
export class UserInput extends CoreUserInput {
|
|
10
13
|
// Extend UserInput here
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import { Field, ObjectType } from '@nestjs/graphql';
|
|
2
2
|
|
|
3
|
+
import { Restricted } from '../../../../core/common/decorators/restricted.decorator';
|
|
4
|
+
import { RoleEnum } from '../../../../core/common/enums/role.enum';
|
|
3
5
|
import { User } from '../user.model';
|
|
4
6
|
|
|
7
|
+
@Restricted(RoleEnum.ADMIN)
|
|
5
8
|
@ObjectType({ description: 'Result of find and count' })
|
|
6
9
|
export class FindAndCountUsersResult {
|
|
10
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
7
11
|
@Field(() => [User], { description: 'Found users' })
|
|
8
12
|
items: User[];
|
|
9
13
|
|
|
14
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
10
15
|
@Field({ description: 'Total count (skip/offset and limit/take are ignored in the count)' })
|
|
11
16
|
totalCount: number;
|
|
12
17
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { Field, ObjectType } from '@nestjs/graphql';
|
|
2
2
|
import { Schema as MongooseSchema, Prop, SchemaFactory } from '@nestjs/mongoose';
|
|
3
|
+
import { IsOptional } from 'class-validator';
|
|
3
4
|
import { Document, Schema } from 'mongoose';
|
|
4
5
|
|
|
6
|
+
import { Restricted } from '../../../core/common/decorators/restricted.decorator';
|
|
5
7
|
import { RoleEnum } from '../../../core/common/enums/role.enum';
|
|
6
8
|
import { CoreUserModel } from '../../../core/modules/user/core-user.model';
|
|
7
9
|
import { PersistenceModel } from '../../common/models/persistence.model';
|
|
@@ -11,6 +13,7 @@ export type UserDocument = Document & User;
|
|
|
11
13
|
/**
|
|
12
14
|
* User model
|
|
13
15
|
*/
|
|
16
|
+
@Restricted(RoleEnum.ADMIN)
|
|
14
17
|
@ObjectType({ description: 'User' })
|
|
15
18
|
@MongooseSchema({ timestamps: true })
|
|
16
19
|
export class User extends CoreUserModel implements PersistenceModel {
|
|
@@ -21,6 +24,7 @@ export class User extends CoreUserModel implements PersistenceModel {
|
|
|
21
24
|
/**
|
|
22
25
|
* URL to avatar file of the user
|
|
23
26
|
*/
|
|
27
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
24
28
|
@Field({ description: 'URL to avatar file of the user', nullable: true })
|
|
25
29
|
@Prop()
|
|
26
30
|
avatar: string = undefined;
|
|
@@ -30,6 +34,7 @@ export class User extends CoreUserModel implements PersistenceModel {
|
|
|
30
34
|
*
|
|
31
35
|
* Not set when created by system
|
|
32
36
|
*/
|
|
37
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
33
38
|
@Field(() => String, {
|
|
34
39
|
description: 'ID of the user who created the object',
|
|
35
40
|
nullable: true,
|
|
@@ -37,11 +42,21 @@ export class User extends CoreUserModel implements PersistenceModel {
|
|
|
37
42
|
@Prop({ ref: 'User', type: Schema.Types.ObjectId })
|
|
38
43
|
createdBy: string = undefined;
|
|
39
44
|
|
|
45
|
+
/**
|
|
46
|
+
* Roles of the user
|
|
47
|
+
*/
|
|
48
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
49
|
+
@Field(type => [String], { description: 'Roles of the user', nullable: true })
|
|
50
|
+
@IsOptional()
|
|
51
|
+
@Prop([String])
|
|
52
|
+
override roles: string[] = undefined;
|
|
53
|
+
|
|
40
54
|
/**
|
|
41
55
|
* ID of the user who updated the object
|
|
42
56
|
*
|
|
43
57
|
* Not set when updated by system
|
|
44
58
|
*/
|
|
59
|
+
@Restricted(RoleEnum.S_USER)
|
|
45
60
|
@Field(() => String, {
|
|
46
61
|
description: 'ID of the user who last updated the object',
|
|
47
62
|
nullable: true,
|
|
@@ -2,10 +2,12 @@ import { Controller, Get, Render } from '@nestjs/common';
|
|
|
2
2
|
|
|
3
3
|
import { ConfigService, RoleEnum, Roles } from '..';
|
|
4
4
|
|
|
5
|
+
@Roles(RoleEnum.ADMIN)
|
|
5
6
|
@Controller()
|
|
6
7
|
export class ServerController {
|
|
7
8
|
constructor(protected configService: ConfigService) {}
|
|
8
9
|
|
|
10
|
+
@Roles(RoleEnum.S_EVERYONE)
|
|
9
11
|
@Get()
|
|
10
12
|
@Render('index')
|
|
11
13
|
root() {
|