tethys.backend/providers/HashDriver/index.ts
Arno Kaimbacher f403c3109f
All checks were successful
CI Pipeline / japa-tests (push) Successful in 54s
- add methods for releasing datasets from submitter
- npm updates
- side menu with child items
- flash messages via HttpContext response (extended via macro)
2023-06-27 18:23:18 +02:00

22 lines
689 B
TypeScript

import { HashDriverContract } from '@ioc:Adonis/Core/Hash';
// const bcrypt = require("bcrypt");
import bcrypt from 'bcryptjs';
const saltRounds = 10;
export class LaravelHash implements HashDriverContract {
public async make(value: string) {
const _hashedValue = bcrypt.hashSync(value, saltRounds);
return _hashedValue;
}
public async verify(hashedValue: string, plainValue: string) {
let newHash: string;
if (hashedValue.includes('$2y$10$')) {
newHash = hashedValue.replace('$2y$10$', '$2a$10$');
} else {
newHash = hashedValue;
}
return await bcrypt.compareSync(plainValue, newHash);
}
}