working on AuthController + CreateAuth

ref #12
This commit is contained in:
2020-12-04 22:43:41 +01:00
parent c4b7ece974
commit 6cb01090d0
2 changed files with 31 additions and 2 deletions

View File

@@ -1,7 +1,9 @@
import { IsEmail, IsOptional, IsString } from 'class-validator';
import { getConnectionManager } from 'typeorm';
import { PasswordNeededError } from '../../errors/AuthError';
import { UsernameOrEmailNeededError } from '../../errors/UserErrors';
import { Auth } from '../entities/Auth';
import { User } from '../entities/User';
export class CreateAuth {
@IsOptional()
@@ -22,9 +24,10 @@ export class CreateAuth {
if (!this.password) {
throw new PasswordNeededError()
}
// const found = await getConnectionManager().get().getRepository(UserGroup).find({ id: g });
const found = await getConnectionManager().get().getRepository(User).find({ where: [{ username: this.username }, { email: this.email }] });
console.log(found);
// TODO: jwt creation + return
// TODO: jwt creation
newAuth.access_token = ""
newAuth.refresh_token = ""
newAuth.access_token_expires_at = 1587349200