fix: login sessions
This commit is contained in:
parent
dc91d0ab8c
commit
cf46450f5f
11 changed files with 179 additions and 27 deletions
|
@ -1,13 +1,12 @@
|
|||
import { PASSWORD_ENTRIES, PASSWORD_ENTRY } from '../../../models/password_entry.ts';
|
||||
import { USER, USERS } from '../../../models/user.ts';
|
||||
import { generateSecret } from 'jsr:@stdext/crypto/utils';
|
||||
import { hash } from 'jsr:@stdext/crypto/hash';
|
||||
import lurid from 'jsr:@andyburke/lurid';
|
||||
import { encodeBase64 } from 'jsr:@std/encoding';
|
||||
import parse_body from '../../../utils/bodyparser.ts';
|
||||
import { create_new_session, SESSION_RESULT } from '../auth/index.ts';
|
||||
import { get_session, get_user, PRECHECK_TABLE, require_user } from '../../../utils/prechecks.ts';
|
||||
import * as CANNED_RESPONSES from '../../../utils/canned_responses.ts';
|
||||
import * as bcrypt from 'jsr:@da/bcrypt';
|
||||
|
||||
// TODO: figure out a better solution for doling out permissions
|
||||
const DEFAULT_USER_PERMISSIONS: string[] = [
|
||||
|
@ -107,8 +106,8 @@ export async function POST(req: Request, meta: Record<string, any>): Promise<Res
|
|||
|
||||
await USERS.create(user);
|
||||
|
||||
const salt = generateSecret();
|
||||
const hashed_password_value = hash('bcrypt', `${password_hash}${salt}`);
|
||||
const salt = await bcrypt.genSalt();
|
||||
const hashed_password_value = await bcrypt.hash(password_hash, salt);
|
||||
|
||||
const password_entry: PASSWORD_ENTRY = {
|
||||
user_id: user.id,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue