auth: hash auth token

Since the auth token will be stored in hashed form in the db, we need to hash each provided auth token in order to search in the db for them.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
Philip Molares 2021-01-17 14:38:05 +01:00 committed by David Mehren
parent 667cf7e915
commit e5545043be
No known key found for this signature in database
GPG key ID: 185982BA4C42B7C3

View file

@ -78,8 +78,9 @@ export class UsersService {
}
async getUserByAuthToken(token: string): Promise<User> {
const hash = this.hashPassword(token);
const accessToken = await this.authTokenRepository.findOne({
where: { accessToken: token },
where: { accessToken: hash },
});
if (accessToken === undefined) {
throw new NotInDBError(`AuthToken '${token}' not found`);