mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-24 20:14:35 -04:00
auth: add hash function
the hash function uses bcrypt with 2^16 iterations. Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
parent
b589dedd2a
commit
667cf7e915
3 changed files with 44 additions and 3 deletions
|
@ -12,6 +12,7 @@ import { ConsoleLoggerService } from '../logger/console-logger.service';
|
|||
import { UserInfoDto } from './user-info.dto';
|
||||
import { User } from './user.entity';
|
||||
import { AuthToken } from './auth-token.entity';
|
||||
import { hash } from 'bcrypt'
|
||||
import crypt from 'crypto';
|
||||
import { AuthTokenDto } from './auth-token.dto';
|
||||
import { AuthTokenWithSecretDto } from './auth-token-with-secret.dto';
|
||||
|
@ -71,6 +72,11 @@ export class UsersService {
|
|||
return user;
|
||||
}
|
||||
|
||||
async hashPassword(password: string): Promise<string> {
|
||||
// hash the password with bcrypt and 2^16 iterations
|
||||
return hash(password, 16)
|
||||
}
|
||||
|
||||
async getUserByAuthToken(token: string): Promise<User> {
|
||||
const accessToken = await this.authTokenRepository.findOne({
|
||||
where: { accessToken: token },
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue