@devmoods/express-extras 0.17.5 → 0.17.8
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/bin/migrate +5 -0
- package/dist/auth.js +21 -22
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +3 -0
- package/package.json +1 -1
- package/bin/migrate.js +0 -10
package/bin/migrate
ADDED
package/dist/auth.js
CHANGED
|
@@ -63,28 +63,27 @@ export function createAuth({ getUserByToken, methods: { emailAndPassword }, filt
|
|
|
63
63
|
type: 'string',
|
|
64
64
|
minLength: 4,
|
|
65
65
|
};
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}));
|
|
66
|
+
if (emailAndPassword) {
|
|
67
|
+
router.post('/reset/:token', validateParams(tokenSchema), validateBody({
|
|
68
|
+
type: 'object',
|
|
69
|
+
properties: {
|
|
70
|
+
password: { type: 'string', minLength: 8 },
|
|
71
|
+
},
|
|
72
|
+
required: ['password'],
|
|
73
|
+
}), route(async (req) => {
|
|
74
|
+
const { password } = req.body;
|
|
75
|
+
const { token } = req.params;
|
|
76
|
+
const email = await redis.get(token);
|
|
77
|
+
if (!email) {
|
|
78
|
+
throw BadRequest('invalid reset token');
|
|
79
|
+
}
|
|
80
|
+
const user = await emailAndPassword(email, skipPasswordCheck);
|
|
81
|
+
await onPasswordChanged?.(user, await hashPassword(password));
|
|
82
|
+
await redis.del(token);
|
|
83
|
+
logger.info('user changed password', { email });
|
|
84
|
+
return 200;
|
|
85
|
+
}));
|
|
86
|
+
}
|
|
88
87
|
router.get('/reset/:token', validateParams(tokenSchema), route(async (req) => {
|
|
89
88
|
const token = req.params.token;
|
|
90
89
|
const email = await redis.get(token);
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import 'dotenv/config';
|
package/dist/cli.js
ADDED
package/package.json
CHANGED