🧹 cleanups
This commit is contained in:
parent
7e4ce00c30
commit
e5b605cc55
@ -5,8 +5,8 @@ import { UserNotFoundError } from '../errors/UserErrors';
|
|||||||
import { CreateAuth } from '../models/creation/CreateAuth';
|
import { CreateAuth } from '../models/creation/CreateAuth';
|
||||||
import { HandleLogout } from '../models/creation/HandleLogout';
|
import { HandleLogout } from '../models/creation/HandleLogout';
|
||||||
import { RefreshAuth } from '../models/creation/RefreshAuth';
|
import { RefreshAuth } from '../models/creation/RefreshAuth';
|
||||||
import { Auth } from '../models/entities/Auth';
|
import { Auth } from '../models/responses/Auth';
|
||||||
import { Logout } from '../models/entities/Logout';
|
import { Logout } from '../models/responses/Logout';
|
||||||
|
|
||||||
@JsonController('/auth')
|
@JsonController('/auth')
|
||||||
export class AuthController {
|
export class AuthController {
|
||||||
|
@ -4,8 +4,8 @@ import * as jsonwebtoken from 'jsonwebtoken';
|
|||||||
import { getConnectionManager } from 'typeorm';
|
import { getConnectionManager } from 'typeorm';
|
||||||
import { InvalidCredentialsError, PasswordNeededError, UserNotFoundError } from '../../errors/AuthError';
|
import { InvalidCredentialsError, PasswordNeededError, UserNotFoundError } from '../../errors/AuthError';
|
||||||
import { UsernameOrEmailNeededError } from '../../errors/UserErrors';
|
import { UsernameOrEmailNeededError } from '../../errors/UserErrors';
|
||||||
import { Auth } from '../entities/Auth';
|
|
||||||
import { User } from '../entities/User';
|
import { User } from '../entities/User';
|
||||||
|
import { Auth } from '../responses/Auth';
|
||||||
|
|
||||||
export class CreateAuth {
|
export class CreateAuth {
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
|
@ -2,8 +2,8 @@ import { IsString } from 'class-validator';
|
|||||||
import * as jsonwebtoken from 'jsonwebtoken';
|
import * as jsonwebtoken from 'jsonwebtoken';
|
||||||
import { getConnectionManager } from 'typeorm';
|
import { getConnectionManager } from 'typeorm';
|
||||||
import { IllegalJWTError, JwtNotProvidedError, RefreshTokenCountInvalidError, UserNotFoundError } from '../../errors/AuthError';
|
import { IllegalJWTError, JwtNotProvidedError, RefreshTokenCountInvalidError, UserNotFoundError } from '../../errors/AuthError';
|
||||||
import { Logout } from '../entities/Logout';
|
|
||||||
import { User } from '../entities/User';
|
import { User } from '../entities/User';
|
||||||
|
import { Logout } from '../responses/Logout';
|
||||||
|
|
||||||
export class HandleLogout {
|
export class HandleLogout {
|
||||||
@IsString()
|
@IsString()
|
||||||
@ -20,7 +20,6 @@ export class HandleLogout {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new IllegalJWTError()
|
throw new IllegalJWTError()
|
||||||
}
|
}
|
||||||
logout.access_token = this.token
|
|
||||||
logout.timestamp = Math.floor(Date.now() / 1000)
|
logout.timestamp = Math.floor(Date.now() / 1000)
|
||||||
let found_user: User = await getConnectionManager().get().getRepository(User).findOne({ id: decoded["userid"] });
|
let found_user: User = await getConnectionManager().get().getRepository(User).findOne({ id: decoded["userid"] });
|
||||||
if (!found_user) {
|
if (!found_user) {
|
||||||
|
@ -2,8 +2,8 @@ import { IsString } from 'class-validator';
|
|||||||
import * as jsonwebtoken from 'jsonwebtoken';
|
import * as jsonwebtoken from 'jsonwebtoken';
|
||||||
import { getConnectionManager } from 'typeorm';
|
import { getConnectionManager } from 'typeorm';
|
||||||
import { IllegalJWTError, JwtNotProvidedError, RefreshTokenCountInvalidError, UserNotFoundError } from '../../errors/AuthError';
|
import { IllegalJWTError, JwtNotProvidedError, RefreshTokenCountInvalidError, UserNotFoundError } from '../../errors/AuthError';
|
||||||
import { Auth } from '../entities/Auth';
|
|
||||||
import { User } from '../entities/User';
|
import { User } from '../entities/User';
|
||||||
|
import { Auth } from '../responses/Auth';
|
||||||
|
|
||||||
export class RefreshAuth {
|
export class RefreshAuth {
|
||||||
@IsString()
|
@IsString()
|
||||||
|
@ -4,11 +4,6 @@ import { IsString } from 'class-validator';
|
|||||||
* Defines a Logout object
|
* Defines a Logout object
|
||||||
*/
|
*/
|
||||||
export class Logout {
|
export class Logout {
|
||||||
/**
|
|
||||||
* access_token - JWT shortterm access token
|
|
||||||
*/
|
|
||||||
@IsString()
|
|
||||||
access_token: string;
|
|
||||||
/**
|
/**
|
||||||
* timestamp of logout
|
* timestamp of logout
|
||||||
*/
|
*/
|
Loading…
x
Reference in New Issue
Block a user