private: save token hashed

Auth tokens are now saved in hashed form.

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

View file

@ -41,7 +41,8 @@ export class UsersService {
let accessToken = ''; let accessToken = '';
for (let i = 0; i < 100; i++) { for (let i = 0; i < 100; i++) {
try { try {
accessToken = crypt.randomBytes(64).toString(); const randomString = crypt.randomBytes(64).toString();
accessToken = await this.hashPassword(randomString);
await this.getUserByAuthToken(accessToken); await this.getUserByAuthToken(accessToken);
} catch (NotInDBError) { } catch (NotInDBError) {
const token = AuthToken.create(user, identifier, accessToken); const token = AuthToken.create(user, identifier, accessToken);