Skip to content

Commit 416e52e

Browse files
committed
refactor(api): Use shouldChangePassword from User model
1 parent 881fb07 commit 416e52e

File tree

1 file changed

+1
-11
lines changed

1 file changed

+1
-11
lines changed

api/src/identity-access-management/domain/usecases/authenticate-user.js

+1-11
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
import lodash from 'lodash';
2-
3-
const { get } = lodash;
4-
51
import { PIX_ADMIN, PIX_ORGA } from '../../../authorization/domain/constants.js';
62
import { ForbiddenAccess, LocaleFormatError, LocaleNotSupportedError } from '../../../shared/domain/errors.js';
73
import { MissingOrInvalidCredentialsError, UserShouldChangePasswordError } from '../errors.js';
@@ -39,13 +35,7 @@ const authenticateUser = async function ({
3935
userRepository,
4036
});
4137

42-
// TODO: étrange ?
43-
const shouldChangePassword = get(
44-
foundUser,
45-
'authenticationMethods[0].authenticationComplement.shouldChangePassword',
46-
);
47-
48-
if (shouldChangePassword) {
38+
if (foundUser.shouldChangePassword) {
4939
const passwordResetToken = tokenService.createPasswordResetToken(foundUser.id);
5040
throw new UserShouldChangePasswordError(undefined, passwordResetToken);
5141
}

0 commit comments

Comments
 (0)