@lenne.tech/nest-server 9.0.14 → 9.0.16
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/modules/user/core-user.model.d.ts +1 -0
- package/dist/core/modules/user/core-user.model.js +6 -0
- package/dist/core/modules/user/core-user.model.js.map +1 -1
- package/dist/core/modules/user/core-user.service.d.ts +1 -1
- package/dist/core/modules/user/core-user.service.js +2 -2
- package/dist/core/modules/user/core-user.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/core/modules/user/core-user.model.ts +7 -0
- package/src/core/modules/user/core-user.service.ts +6 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lenne.tech/nest-server",
|
|
3
|
-
"version": "9.0.
|
|
3
|
+
"version": "9.0.16",
|
|
4
4
|
"description": "Modern, fast, powerful Node.js web framework in TypeScript based on Nest with a GraphQL API and a connection to MongoDB (or other databases).",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"node",
|
|
@@ -84,6 +84,13 @@ export abstract class CoreUserModel extends CorePersistenceModel {
|
|
|
84
84
|
@Prop({ type: Boolean })
|
|
85
85
|
verified: boolean = undefined;
|
|
86
86
|
|
|
87
|
+
/**
|
|
88
|
+
* Verification date
|
|
89
|
+
*/
|
|
90
|
+
@Field({ description: 'Verified date', nullable: true })
|
|
91
|
+
@Prop()
|
|
92
|
+
verifiedAt: Date = undefined;
|
|
93
|
+
|
|
87
94
|
// ===================================================================================================================
|
|
88
95
|
// Methods
|
|
89
96
|
// ===================================================================================================================
|
|
@@ -98,22 +98,25 @@ export abstract class CoreUserService<
|
|
|
98
98
|
/**
|
|
99
99
|
* Verify user with token
|
|
100
100
|
*/
|
|
101
|
-
async verify(token: string, serviceOptions?: ServiceOptions): Promise<TUser> {
|
|
101
|
+
async verify(token: string, serviceOptions?: ServiceOptions): Promise<TUser | string> {
|
|
102
102
|
// Get user
|
|
103
103
|
const dbObject = await this.mainDbModel.findOne({ verificationToken: token }).exec();
|
|
104
104
|
if (!dbObject) {
|
|
105
105
|
throw new NotFoundException(`No user found with verify token: ${token}`);
|
|
106
106
|
}
|
|
107
|
+
|
|
107
108
|
if (!dbObject.verificationToken) {
|
|
108
109
|
throw new Error('User has no token');
|
|
109
110
|
}
|
|
111
|
+
|
|
110
112
|
if (dbObject.verified) {
|
|
111
|
-
|
|
113
|
+
return 'User already verified';
|
|
112
114
|
}
|
|
115
|
+
|
|
113
116
|
return this.process(
|
|
114
117
|
async () => {
|
|
115
118
|
// Update and return user
|
|
116
|
-
return await assignPlain(dbObject, { verified: true,
|
|
119
|
+
return await assignPlain(dbObject, { verified: true, verifiedAt: new Date() }).save();
|
|
117
120
|
},
|
|
118
121
|
{ dbObject, serviceOptions }
|
|
119
122
|
);
|