@lenne.tech/nest-server 8.1.0 → 8.2.0
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/config.env.js +3 -2
- package/dist/config.env.js.map +1 -1
- package/dist/core/common/decorators/restricted.decorator.d.ts +2 -0
- package/dist/core/common/decorators/restricted.decorator.js +10 -7
- package/dist/core/common/decorators/restricted.decorator.js.map +1 -1
- package/dist/core/common/helpers/input.helper.d.ts +12 -2
- package/dist/core/common/helpers/input.helper.js +50 -11
- package/dist/core/common/helpers/input.helper.js.map +1 -1
- package/dist/core/common/interfaces/service-options.interface.d.ts +6 -0
- package/dist/core/common/models/core-model.model.d.ts +1 -1
- package/dist/core/common/models/core-model.model.js.map +1 -1
- package/dist/core/common/pipes/check-input.pipe.js +1 -1
- package/dist/core/common/pipes/check-input.pipe.js.map +1 -1
- package/dist/core/common/services/crud.service.js +17 -19
- package/dist/core/common/services/crud.service.js.map +1 -1
- package/dist/core/common/services/module.service.d.ts +13 -1
- package/dist/core/common/services/module.service.js +39 -4
- package/dist/core/common/services/module.service.js.map +1 -1
- package/dist/core/common/types/ids.type.d.ts +8 -0
- package/dist/core/common/types/ids.type.js +3 -0
- package/dist/core/common/types/ids.type.js.map +1 -0
- package/dist/core/modules/auth/guards/roles.guard.js.map +1 -1
- package/dist/core/modules/user/core-user.service.js +38 -35
- package/dist/core/modules/user/core-user.service.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/server/modules/user/user.model.d.ts +1 -1
- package/dist/server/modules/user/user.resolver.d.ts +2 -2
- package/dist/server/modules/user/user.resolver.js +30 -14
- package/dist/server/modules/user/user.resolver.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +37 -37
- package/src/config.env.ts +3 -2
- package/src/core/common/decorators/restricted.decorator.ts +16 -10
- package/src/core/common/helpers/input.helper.ts +63 -14
- package/src/core/common/interfaces/service-options.interface.ts +19 -1
- package/src/core/common/models/core-model.model.ts +1 -1
- package/src/core/common/pipes/check-input.pipe.ts +1 -1
- package/src/core/common/services/crud.service.ts +17 -22
- package/src/core/common/services/module.service.ts +75 -9
- package/src/core/common/types/ids.type.ts +7 -0
- package/src/core/modules/auth/guards/roles.guard.ts +1 -1
- package/src/core/modules/user/core-user.service.ts +42 -44
- package/src/index.ts +1 -0
- package/src/server/modules/user/user.resolver.ts +26 -20
|
@@ -19,6 +19,11 @@ class CoreUserService extends crud_service_1.CrudService {
|
|
|
19
19
|
const createdUser = new this.mainDbModel(Object.assign(Object.assign({}, data.input), { verificationToken: crypto.randomBytes(32).toString('hex') }));
|
|
20
20
|
try {
|
|
21
21
|
await createdUser.save();
|
|
22
|
+
if (!createdUser.ownerIds) {
|
|
23
|
+
createdUser.ownerIds = [];
|
|
24
|
+
}
|
|
25
|
+
createdUser.ownerIds.push(createdUser.id);
|
|
26
|
+
await createdUser.save();
|
|
22
27
|
}
|
|
23
28
|
catch (error) {
|
|
24
29
|
if (error.code === 11000) {
|
|
@@ -32,13 +37,11 @@ class CoreUserService extends crud_service_1.CrudService {
|
|
|
32
37
|
}, { input, serviceOptions });
|
|
33
38
|
}
|
|
34
39
|
async getViaEmail(email, serviceOptions) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
return user;
|
|
41
|
-
}, { serviceOptions });
|
|
40
|
+
const dbObject = await this.mainDbModel.findOne({ email }).exec();
|
|
41
|
+
if (!dbObject) {
|
|
42
|
+
throw new common_1.NotFoundException(`No user found with email: ${email}`);
|
|
43
|
+
}
|
|
44
|
+
return this.process(async () => dbObject, { dbObject, serviceOptions });
|
|
42
45
|
}
|
|
43
46
|
async getVerifiedState(token, serviceOptions) {
|
|
44
47
|
const user = await this.mainDbModel.findOne({ verificationToken: token }).exec();
|
|
@@ -48,48 +51,48 @@ class CoreUserService extends crud_service_1.CrudService {
|
|
|
48
51
|
return user.verified;
|
|
49
52
|
}
|
|
50
53
|
async verify(token, serviceOptions) {
|
|
54
|
+
const dbObject = await this.mainDbModel.findOne({ verificationToken: token }).exec();
|
|
55
|
+
if (!dbObject) {
|
|
56
|
+
throw new common_1.NotFoundException(`No user found with verify token: ${token}`);
|
|
57
|
+
}
|
|
58
|
+
if (!dbObject.verificationToken) {
|
|
59
|
+
throw new Error('User has no token');
|
|
60
|
+
}
|
|
61
|
+
if (dbObject.verified) {
|
|
62
|
+
throw new Error('User already verified');
|
|
63
|
+
}
|
|
51
64
|
return this.process(async () => {
|
|
52
|
-
|
|
53
|
-
if (!user) {
|
|
54
|
-
throw new common_1.NotFoundException(`No user found with verify token: ${token}`);
|
|
55
|
-
}
|
|
56
|
-
if (!user.verificationToken) {
|
|
57
|
-
throw new Error('User has no token');
|
|
58
|
-
}
|
|
59
|
-
if (user.verified) {
|
|
60
|
-
throw new Error('User already verified');
|
|
61
|
-
}
|
|
62
|
-
await Object.assign(user, {
|
|
65
|
+
await Object.assign(dbObject, {
|
|
63
66
|
verified: true,
|
|
64
67
|
verificationToken: null,
|
|
65
68
|
}).save();
|
|
66
|
-
return
|
|
67
|
-
}, { serviceOptions });
|
|
69
|
+
return dbObject;
|
|
70
|
+
}, { dbObject, serviceOptions });
|
|
68
71
|
}
|
|
69
72
|
async resetPassword(token, newPassword, serviceOptions) {
|
|
73
|
+
const dbObject = await this.mainDbModel.findOne({ passwordResetToken: token }).exec();
|
|
74
|
+
if (!dbObject) {
|
|
75
|
+
throw new common_1.NotFoundException(`No user found with password reset token: ${token}`);
|
|
76
|
+
}
|
|
70
77
|
return this.process(async () => {
|
|
71
|
-
|
|
72
|
-
if (!user) {
|
|
73
|
-
throw new common_1.NotFoundException(`No user found with password reset token: ${token}`);
|
|
74
|
-
}
|
|
75
|
-
await Object.assign(user, {
|
|
78
|
+
await Object.assign(dbObject, {
|
|
76
79
|
password: await bcrypt.hash(newPassword, 10),
|
|
77
80
|
passwordResetToken: null,
|
|
78
81
|
}).save();
|
|
79
|
-
return
|
|
80
|
-
}, { serviceOptions });
|
|
82
|
+
return dbObject;
|
|
83
|
+
}, { dbObject, serviceOptions });
|
|
81
84
|
}
|
|
82
85
|
async setPasswordResetTokenForEmail(email, serviceOptions) {
|
|
86
|
+
const dbObject = await this.mainDbModel.findOne({ email }).exec();
|
|
87
|
+
if (!dbObject) {
|
|
88
|
+
throw new common_1.NotFoundException(`No user found with email: ${email}`);
|
|
89
|
+
}
|
|
83
90
|
return this.process(async () => {
|
|
84
|
-
const user = await this.mainDbModel.findOne({ email }).exec();
|
|
85
|
-
if (!user) {
|
|
86
|
-
throw new common_1.NotFoundException(`No user found with email: ${email}`);
|
|
87
|
-
}
|
|
88
91
|
const resetToken = crypto.randomBytes(32).toString('hex');
|
|
89
|
-
|
|
90
|
-
await
|
|
91
|
-
return
|
|
92
|
-
}, { serviceOptions });
|
|
92
|
+
dbObject.passwordResetToken = resetToken;
|
|
93
|
+
await dbObject.save();
|
|
94
|
+
return dbObject;
|
|
95
|
+
}, { dbObject, serviceOptions });
|
|
93
96
|
}
|
|
94
97
|
async setRoles(userId, roles, serviceOptions) {
|
|
95
98
|
if (!Array.isArray(roles)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core-user.service.js","sourceRoot":"","sources":["../../../../src/core/modules/user/core-user.service.ts"],"names":[],"mappings":";;;AAAA,2CAAsG;AACtG,iCAAiC;AACjC,iCAAiC;AAEjC,sEAA2D;AAE3D,qEAAiE;AAUjE,MAAsB,eAIpB,SAAQ,0BAAkB;IAC1B,YACY,YAA0B,EACjB,WAAoC,EAC7C,oBAAiD;QAE3D,KAAK,EAAE,CAAC;QAJE,iBAAY,GAAZ,YAAY,CAAc;QACjB,gBAAW,GAAX,WAAW,CAAyB;QAC7C,yBAAoB,GAApB,oBAAoB,CAA6B;IAG7D,CAAC;IASD,KAAK,CAAC,MAAM,CAAC,KAAU,EAAE,cAA+B;QACtD,IAAA,qBAAK,EAAC,EAAE,YAAY,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,cAAc,CAAC,CAAC;QAC1D,OAAO,IAAI,CAAC,OAAO,CACjB,KAAK,EAAE,IAAI,EAAE,EAAE;YAEb,MAAM,WAAW,GAAG,IAAI,IAAI,CAAC,WAAW,iCACnC,IAAI,CAAC,KAAK,KACb,iBAAiB,EAAE,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,IACzD,CAAC;YAGH,IAAI;gBACF,MAAM,WAAW,CAAC,IAAI,EAAE,CAAC;aAC1B;YAAC,OAAO,KAAK,EAAE;gBACd,IAAI,KAAK,CAAC,IAAI,KAAK,KAAK,EAAE;oBACxB,MAAM,IAAI,qCAA4B,CACpC,4BAA6B,IAAI,CAAC,KAAa,CAAC,KAAK,kBAAkB,CACxE,CAAC;iBACH;qBAAM;oBACL,MAAM,IAAI,qCAA4B,EAAE,CAAC;iBAC1C;aACF;YAGD,OAAO,WAAW,CAAC;QACrB,CAAC,EACD,EAAE,KAAK,EAAE,cAAc,EAAE,CAC1B,CAAC;IACJ,CAAC;IAKD,KAAK,CAAC,WAAW,CAAC,KAAa,EAAE,cAA+B;QAC9D,
|
|
1
|
+
{"version":3,"file":"core-user.service.js","sourceRoot":"","sources":["../../../../src/core/modules/user/core-user.service.ts"],"names":[],"mappings":";;;AAAA,2CAAsG;AACtG,iCAAiC;AACjC,iCAAiC;AAEjC,sEAA2D;AAE3D,qEAAiE;AAUjE,MAAsB,eAIpB,SAAQ,0BAAkB;IAC1B,YACY,YAA0B,EACjB,WAAoC,EAC7C,oBAAiD;QAE3D,KAAK,EAAE,CAAC;QAJE,iBAAY,GAAZ,YAAY,CAAc;QACjB,gBAAW,GAAX,WAAW,CAAyB;QAC7C,yBAAoB,GAApB,oBAAoB,CAA6B;IAG7D,CAAC;IASD,KAAK,CAAC,MAAM,CAAC,KAAU,EAAE,cAA+B;QACtD,IAAA,qBAAK,EAAC,EAAE,YA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AAe,EAAE,cAA+B;QAE7E,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;YACzB,MAAM,IAAI,4BAAmB,CAAC,eAAe,CAAC,CAAC;SAChD;QAGD,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAC,EAAE;YAClD,MAAM,IAAI,4BAAmB,CAAC,+BAA+B,CAAC,CAAC;SAChE;QAGD,OAAO,IAAI,CAAC,OAAO,CACjB,KAAK,EAAE,IAAI,EAAE,EAAE;YACb,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,iBAAiB,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;QAC5E,CAAC,EACD,EAAE,cAAc,EAAE,CACnB,CAAC;IACJ,CAAC;CACF;AAnLD,0CAmLC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -44,6 +44,7 @@ export * from './core/common/services/module.service';
|
|
|
44
44
|
export * from './core/common/services/template.service';
|
|
45
45
|
export * from './core/common/types/core-model-constructor.type';
|
|
46
46
|
export * from './core/common/types/field-selection.type';
|
|
47
|
+
export * from './core/common/types/ids.type';
|
|
47
48
|
export * from './core/common/types/plain-input.type';
|
|
48
49
|
export * from './core/common/types/string-or-object-id.type';
|
|
49
50
|
export * from './core/modules/auth/guards/auth.guard';
|
package/dist/index.js
CHANGED
|
@@ -60,6 +60,7 @@ __exportStar(require("./core/common/services/module.service"), exports);
|
|
|
60
60
|
__exportStar(require("./core/common/services/template.service"), exports);
|
|
61
61
|
__exportStar(require("./core/common/types/core-model-constructor.type"), exports);
|
|
62
62
|
__exportStar(require("./core/common/types/field-selection.type"), exports);
|
|
63
|
+
__exportStar(require("./core/common/types/ids.type"), exports);
|
|
63
64
|
__exportStar(require("./core/common/types/plain-input.type"), exports);
|
|
64
65
|
__exportStar(require("./core/common/types/string-or-object-id.type"), exports);
|
|
65
66
|
__exportStar(require("./core/modules/auth/guards/auth.guard"), exports);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAIA,gDAA8B;AAK9B,iEAA+C;AAC/C,qEAAmD;AACnD,kFAAgE;AAChE,+EAA6D;AAC7D,gFAA8D;AAC9D,2EAAyD;AACzD,+EAA6D;AAC7D,4EAA0D;AAC1D,gEAA8C;AAC9C,sEAAoD;AACpD,sEAAoD;AACpD,uEAAqD;AACrD,kEAAgD;AAChD,oEAAkD;AAClD,sEAAoD;AACpD,uEAAqD;AACrD,qEAAmD;AACnD,qEAAmD;AACnD,uEAAqD;AACrD,6EAA2D;AAC3D,wEAAsD;AACtD,oEAAkD;AAClD,2EAAyD;AACzD,kEAAgD;AAChD,wFAAsE;AACtE,4FAA0E;AAC1E,qFAAmE;AACnE,sFAAoE;AACpE,oFAAkE;AAClE,qFAAmE;AACnE,wEAAsD;AACtD,8EAA4D;AAC5D,uEAAqD;AACrD,4EAA0D;AAC1D,mEAAiD;AACjD,oEAAkD;AAClD,oEAAkD;AAClD,wEAAsD;AACtD,sEAAoD;AACpD,uEAAqD;AACrD,yEAAuD;AACvD,wEAAsD;AACtD,0EAAwD;AACxD,kFAAgE;AAChE,2EAAyD;AACzD,uEAAqD;AACrD,+EAA6D;AAM7D,wEAAsD;AACtD,yEAAuD;AACvD,0FAAwE;AACxE,uFAAqE;AACrE,iFAA+D;AAC/D,sFAAoE;AACpE,sEAAoD;AACpD,uEAAqD;AACrD,yEAAuD;AACvD,mEAAiD;AAMjD,6EAA2D;AAC3D,oFAAkE;AAClE,sEAAoD;AACpD,wEAAsD;AAMtD,qDAAmC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAIA,gDAA8B;AAK9B,iEAA+C;AAC/C,qEAAmD;AACnD,kFAAgE;AAChE,+EAA6D;AAC7D,gFAA8D;AAC9D,2EAAyD;AACzD,+EAA6D;AAC7D,4EAA0D;AAC1D,gEAA8C;AAC9C,sEAAoD;AACpD,sEAAoD;AACpD,uEAAqD;AACrD,kEAAgD;AAChD,oEAAkD;AAClD,sEAAoD;AACpD,uEAAqD;AACrD,qEAAmD;AACnD,qEAAmD;AACnD,uEAAqD;AACrD,6EAA2D;AAC3D,wEAAsD;AACtD,oEAAkD;AAClD,2EAAyD;AACzD,kEAAgD;AAChD,wFAAsE;AACtE,4FAA0E;AAC1E,qFAAmE;AACnE,sFAAoE;AACpE,oFAAkE;AAClE,qFAAmE;AACnE,wEAAsD;AACtD,8EAA4D;AAC5D,uEAAqD;AACrD,4EAA0D;AAC1D,mEAAiD;AACjD,oEAAkD;AAClD,oEAAkD;AAClD,wEAAsD;AACtD,sEAAoD;AACpD,uEAAqD;AACrD,yEAAuD;AACvD,wEAAsD;AACtD,0EAAwD;AACxD,kFAAgE;AAChE,2EAAyD;AACzD,+DAA6C;AAC7C,uEAAqD;AACrD,+EAA6D;AAM7D,wEAAsD;AACtD,yEAAuD;AACvD,0FAAwE;AACxE,uFAAqE;AACrE,iFAA+D;AAC/D,sFAAoE;AACpE,sEAAoD;AACpD,uEAAqD;AACrD,yEAAuD;AACvD,mEAAiD;AAMjD,6EAA2D;AAC3D,oFAAkE;AAClE,sEAAoD;AACpD,wEAAsD;AAMtD,qDAAmC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
/// <reference types="mongoose/types/pipelinestage" />
|
|
2
1
|
/// <reference types="mongoose/types/aggregate" />
|
|
3
2
|
/// <reference types="mongoose/types/connection" />
|
|
4
3
|
/// <reference types="mongoose/types/cursor" />
|
|
5
4
|
/// <reference types="mongoose/types/document" />
|
|
6
5
|
/// <reference types="mongoose/types/error" />
|
|
7
6
|
/// <reference types="mongoose/types/mongooseoptions" />
|
|
7
|
+
/// <reference types="mongoose/types/pipelinestage" />
|
|
8
8
|
/// <reference types="mongoose/types/schemaoptions" />
|
|
9
9
|
import { CoreUserModel } from '../../../core/modules/user/core-user.model';
|
|
10
10
|
import { PersistenceModel } from '../../common/models/persistence.model';
|
|
@@ -10,11 +10,11 @@ export declare class UserResolver {
|
|
|
10
10
|
protected readonly pubSub: PubSub;
|
|
11
11
|
constructor(userService: UserService, pubSub: PubSub);
|
|
12
12
|
findUsers(info: GraphQLResolveInfo, args?: FilterArgs): Promise<User[]>;
|
|
13
|
-
getUser(id: string, info: GraphQLResolveInfo): Promise<User>;
|
|
13
|
+
getUser(id: string, info: GraphQLResolveInfo, user: User): Promise<User>;
|
|
14
14
|
getVerifiedState(token: string): Promise<boolean>;
|
|
15
15
|
requestPasswordResetMail(email: string): Promise<boolean>;
|
|
16
16
|
createUser(input: UserCreateInput, user: User, info: GraphQLResolveInfo): Promise<User>;
|
|
17
|
-
deleteUser(id: string, info: GraphQLResolveInfo): Promise<User>;
|
|
17
|
+
deleteUser(id: string, info: GraphQLResolveInfo, user: User): Promise<User>;
|
|
18
18
|
resetPassword(token: string, password: string): Promise<boolean>;
|
|
19
19
|
updateUser(input: UserInput, id: string, user: User, info: GraphQLResolveInfo): Promise<User>;
|
|
20
20
|
verifyUser(token: string): Promise<boolean>;
|
|
@@ -20,7 +20,6 @@ const filter_args_1 = require("../../../core/common/args/filter.args");
|
|
|
20
20
|
const graphql_user_decorator_1 = require("../../../core/common/decorators/graphql-user.decorator");
|
|
21
21
|
const roles_decorator_1 = require("../../../core/common/decorators/roles.decorator");
|
|
22
22
|
const role_enum_1 = require("../../../core/common/enums/role.enum");
|
|
23
|
-
const input_helper_1 = require("../../../core/common/helpers/input.helper");
|
|
24
23
|
const user_create_input_1 = require("./inputs/user-create.input");
|
|
25
24
|
const user_input_1 = require("./inputs/user.input");
|
|
26
25
|
const user_model_1 = require("./user.model");
|
|
@@ -31,10 +30,17 @@ let UserResolver = class UserResolver {
|
|
|
31
30
|
this.pubSub = pubSub;
|
|
32
31
|
}
|
|
33
32
|
async findUsers(info, args) {
|
|
34
|
-
return await this.userService.find(args, {
|
|
33
|
+
return await this.userService.find(args, {
|
|
34
|
+
fieldSelection: { info, select: 'findUsers' },
|
|
35
|
+
inputType: filter_args_1.FilterArgs,
|
|
36
|
+
});
|
|
35
37
|
}
|
|
36
|
-
async getUser(id, info) {
|
|
37
|
-
return await this.userService.get(id, {
|
|
38
|
+
async getUser(id, info, user) {
|
|
39
|
+
return await this.userService.get(id, {
|
|
40
|
+
currentUser: user,
|
|
41
|
+
fieldSelection: { info, select: 'getUser' },
|
|
42
|
+
roles: [role_enum_1.RoleEnum.OWNER, role_enum_1.RoleEnum.ADMIN],
|
|
43
|
+
});
|
|
38
44
|
}
|
|
39
45
|
async getVerifiedState(token) {
|
|
40
46
|
return await this.userService.getVerifiedState(token);
|
|
@@ -43,20 +49,28 @@ let UserResolver = class UserResolver {
|
|
|
43
49
|
return !!(await this.userService.sendPasswordResetMail(email));
|
|
44
50
|
}
|
|
45
51
|
async createUser(input, user, info) {
|
|
46
|
-
|
|
47
|
-
|
|
52
|
+
return await this.userService.create(input, {
|
|
53
|
+
currentUser: user,
|
|
54
|
+
fieldSelection: { info, select: 'createUser' },
|
|
55
|
+
inputType: user_create_input_1.UserCreateInput,
|
|
56
|
+
});
|
|
48
57
|
}
|
|
49
|
-
async deleteUser(id, info) {
|
|
50
|
-
return await this.userService.delete(id, {
|
|
58
|
+
async deleteUser(id, info, user) {
|
|
59
|
+
return await this.userService.delete(id, {
|
|
60
|
+
currentUser: user,
|
|
61
|
+
fieldSelection: { info, select: 'deleteUser' },
|
|
62
|
+
roles: [role_enum_1.RoleEnum.ADMIN, role_enum_1.RoleEnum.OWNER],
|
|
63
|
+
});
|
|
51
64
|
}
|
|
52
65
|
async resetPassword(token, password) {
|
|
53
66
|
return !!(await this.userService.resetPassword(token, password));
|
|
54
67
|
}
|
|
55
68
|
async updateUser(input, id, user, info) {
|
|
56
|
-
input = await (0, input_helper_1.check)(input, user, user_input_1.UserInput);
|
|
57
69
|
return await this.userService.update(id, input, {
|
|
58
70
|
currentUser: user,
|
|
59
71
|
fieldSelection: { info, select: 'updateUser' },
|
|
72
|
+
inputType: user_input_1.UserInput,
|
|
73
|
+
roles: [role_enum_1.RoleEnum.ADMIN, role_enum_1.RoleEnum.OWNER],
|
|
60
74
|
});
|
|
61
75
|
}
|
|
62
76
|
async verifyUser(token) {
|
|
@@ -76,12 +90,13 @@ __decorate([
|
|
|
76
90
|
__metadata("design:returntype", Promise)
|
|
77
91
|
], UserResolver.prototype, "findUsers", null);
|
|
78
92
|
__decorate([
|
|
79
|
-
(0, roles_decorator_1.Roles)(role_enum_1.RoleEnum.
|
|
93
|
+
(0, roles_decorator_1.Roles)(role_enum_1.RoleEnum.USER),
|
|
80
94
|
(0, graphql_1.Query)((returns) => user_model_1.User, { description: 'Get user with specified ID' }),
|
|
81
95
|
__param(0, (0, graphql_1.Args)('id')),
|
|
82
96
|
__param(1, (0, graphql_1.Info)()),
|
|
97
|
+
__param(2, (0, graphql_user_decorator_1.GraphQLUser)()),
|
|
83
98
|
__metadata("design:type", Function),
|
|
84
|
-
__metadata("design:paramtypes", [String, Object]),
|
|
99
|
+
__metadata("design:paramtypes", [String, Object, user_model_1.User]),
|
|
85
100
|
__metadata("design:returntype", Promise)
|
|
86
101
|
], UserResolver.prototype, "getUser", null);
|
|
87
102
|
__decorate([
|
|
@@ -109,12 +124,13 @@ __decorate([
|
|
|
109
124
|
__metadata("design:returntype", Promise)
|
|
110
125
|
], UserResolver.prototype, "createUser", null);
|
|
111
126
|
__decorate([
|
|
112
|
-
(0, roles_decorator_1.Roles)(role_enum_1.RoleEnum.
|
|
127
|
+
(0, roles_decorator_1.Roles)(role_enum_1.RoleEnum.USER),
|
|
113
128
|
(0, graphql_1.Mutation)((returns) => user_model_1.User, { description: 'Delete existing user' }),
|
|
114
129
|
__param(0, (0, graphql_1.Args)('id')),
|
|
115
130
|
__param(1, (0, graphql_1.Info)()),
|
|
131
|
+
__param(2, (0, graphql_user_decorator_1.GraphQLUser)()),
|
|
116
132
|
__metadata("design:type", Function),
|
|
117
|
-
__metadata("design:paramtypes", [String, Object]),
|
|
133
|
+
__metadata("design:paramtypes", [String, Object, user_model_1.User]),
|
|
118
134
|
__metadata("design:returntype", Promise)
|
|
119
135
|
], UserResolver.prototype, "deleteUser", null);
|
|
120
136
|
__decorate([
|
|
@@ -126,7 +142,7 @@ __decorate([
|
|
|
126
142
|
__metadata("design:returntype", Promise)
|
|
127
143
|
], UserResolver.prototype, "resetPassword", null);
|
|
128
144
|
__decorate([
|
|
129
|
-
(0, roles_decorator_1.Roles)(role_enum_1.RoleEnum.
|
|
145
|
+
(0, roles_decorator_1.Roles)(role_enum_1.RoleEnum.USER),
|
|
130
146
|
(0, graphql_1.Mutation)((returns) => user_model_1.User, { description: 'Update existing user' }),
|
|
131
147
|
__param(0, (0, graphql_1.Args)('input')),
|
|
132
148
|
__param(1, (0, graphql_1.Args)('id')),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.resolver.js","sourceRoot":"","sources":["../../../../src/server/modules/user/user.resolver.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAwC;AACxC,6CAAsF;AAEtF,iEAA+C;AAC/C,uEAAmE;AACnE,mGAAqF;AACrF,qFAAwE;AACxE,oEAAgE;AAChE,
|
|
1
|
+
{"version":3,"file":"user.resolver.js","sourceRoot":"","sources":["../../../../src/server/modules/user/user.resolver.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAwC;AACxC,6CAAsF;AAEtF,iEAA+C;AAC/C,uEAAmE;AACnE,mGAAqF;AACrF,qFAAwE;AACxE,oEAAgE;AAChE,kEAA6D;AAC7D,oDAAgD;AAChD,6CAAoC;AACpC,iDAA6C;AAM7C,IAAa,YAAY,GAAzB,MAAa,YAAY;IAIvB,YAA+B,WAAwB,EAAwC,MAAc;QAA9E,gBAAW,GAAX,WAAW,CAAa;QAAwC,WAAM,GAAN,MAAM,CAAQ;IA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