Skip to content

Commit cead435

Browse files
Update README.md (#41)
Corrected bug in VerifyFunction.LocalPasswordFn, which must throw an error in string format. (and not a HttpErrors format from Repository)
1 parent b515761 commit cead435

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

README.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -470,14 +470,18 @@ export class LocalPasswordVerifyProvider
470470
constructor(
471471
@repository(UserRepository)
472472
public userRepository: UserRepository,
473-
) {}
473+
) { }
474474

475475
value(): VerifyFunction.LocalPasswordFn {
476-
return async (username, password) => {
477-
const user: User = new User(
478-
await this.userRepository.verifyPassword(username, password),
479-
);
480-
return user;
476+
return async (username: any, password: any) => {
477+
try {
478+
const user: AuthUser = new AuthUser(
479+
await this.userRepository.verifyPassword(username, password),
480+
);
481+
return user;
482+
} catch (error) {
483+
throw new HttpErrors.Unauthorized(AuthErrorKeys.InvalidCredentials).message;
484+
}
481485
};
482486
}
483487
}

0 commit comments

Comments
 (0)