parent
d803704eee
commit
6244c969af
@ -1,6 +1,6 @@
|
|||||||
import { IsEmail, IsOptional, IsString } from 'class-validator';
|
import { IsEmail, IsOptional, IsString } from 'class-validator';
|
||||||
import { getConnectionManager } from 'typeorm';
|
import { getConnectionManager } from 'typeorm';
|
||||||
import { PasswordNeededError } from '../../errors/AuthError';
|
import { PasswordNeededError, UserNotFoundError } from '../../errors/AuthError';
|
||||||
import { UsernameOrEmailNeededError } from '../../errors/UserErrors';
|
import { UsernameOrEmailNeededError } from '../../errors/UserErrors';
|
||||||
import { Auth } from '../entities/Auth';
|
import { Auth } from '../entities/Auth';
|
||||||
import { User } from '../entities/User';
|
import { User } from '../entities/User';
|
||||||
@ -24,8 +24,11 @@ export class CreateAuth {
|
|||||||
if (!this.password) {
|
if (!this.password) {
|
||||||
throw new PasswordNeededError()
|
throw new PasswordNeededError()
|
||||||
}
|
}
|
||||||
const found = await getConnectionManager().get().getRepository(User).find({ where: [{ username: this.username }, { email: this.email }] });
|
const found_users = await getConnectionManager().get().getRepository(User).find({ where: [{ username: this.username }, { email: this.email }] });
|
||||||
console.log(found);
|
console.log(found_users);
|
||||||
|
if (found_users.length === 0) {
|
||||||
|
throw new UserNotFoundError()
|
||||||
|
} else {
|
||||||
|
|
||||||
// TODO: jwt creation
|
// TODO: jwt creation
|
||||||
newAuth.access_token = ""
|
newAuth.access_token = ""
|
||||||
@ -33,7 +36,8 @@ export class CreateAuth {
|
|||||||
newAuth.access_token_expires_at = 1587349200
|
newAuth.access_token_expires_at = 1587349200
|
||||||
newAuth.refresh_token_expires_at = 1587349200
|
newAuth.refresh_token_expires_at = 1587349200
|
||||||
|
|
||||||
console.log(newAuth)
|
console.log(newAuth)
|
||||||
|
}
|
||||||
return newAuth;
|
return newAuth;
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user