Skip to content

Commit 636ebe4

Browse files
committed
fix: reset 2fa secret when resetting password
1 parent 0507d02 commit 636ebe4

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "amber",
33
"description": "Electronic Data Capture system",
4-
"version": "1.3.1",
4+
"version": "1.3.2",
55
"homepage": "",
66
"private": true,
77
"main": "src",

src/hooks/user-totp2fa-reset.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,13 @@ module.exports = (options = {}) => {
99
// sanitize result
1010
delete context.result.totp2faSecret;
1111
}
12-
if (context.result._id && context.data && context.data.action && context.data.action.startsWith('resetPwd')) {
12+
if (context.result.email && context.data && context.data.action && context.data.action.startsWith('resetPwd')) {
1313
// reset 2FA secret
1414
context.result.totp2faEnabled = false;
15-
context.app.service('user').patch(context.result._id, { totp2faSecret: null });
15+
const res = await context.app.service('user').find({ query: { email: context.result.email } });
16+
if (res.data && res.data.length > 0) {
17+
context.app.service('user').patch(res.data[0]._id, { totp2faSecret: null });
18+
}
1619
}
1720
}
1821
return context;

0 commit comments

Comments
 (0)