parent
6244c969af
commit
6ae0c1b955
@ -1,4 +1,5 @@
|
|||||||
import { IsEmail, IsOptional, IsString } from 'class-validator';
|
import { IsEmail, IsOptional, IsString } from 'class-validator';
|
||||||
|
import * as jsonwebtoken from 'jsonwebtoken';
|
||||||
import { getConnectionManager } from 'typeorm';
|
import { getConnectionManager } from 'typeorm';
|
||||||
import { PasswordNeededError, UserNotFoundError } from '../../errors/AuthError';
|
import { PasswordNeededError, UserNotFoundError } from '../../errors/AuthError';
|
||||||
import { UsernameOrEmailNeededError } from '../../errors/UserErrors';
|
import { UsernameOrEmailNeededError } from '../../errors/UserErrors';
|
||||||
@ -29,10 +30,12 @@ export class CreateAuth {
|
|||||||
if (found_users.length === 0) {
|
if (found_users.length === 0) {
|
||||||
throw new UserNotFoundError()
|
throw new UserNotFoundError()
|
||||||
} else {
|
} else {
|
||||||
|
const found_user = found_users[0]
|
||||||
|
const token = jsonwebtoken.sign(found_user, "sec")
|
||||||
|
|
||||||
// TODO: jwt creation
|
// TODO: jwt creation
|
||||||
newAuth.access_token = ""
|
newAuth.access_token = token
|
||||||
newAuth.refresh_token = ""
|
newAuth.refresh_token = token
|
||||||
newAuth.access_token_expires_at = 1587349200
|
newAuth.access_token_expires_at = 1587349200
|
||||||
newAuth.refresh_token_expires_at = 1587349200
|
newAuth.refresh_token_expires_at = 1587349200
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user