parent
3deae2bfeb
commit
01e0d5b94d
@ -7,7 +7,7 @@ import { CreateResetToken } from '../models/actions/create/CreateResetToken';
|
|||||||
import { HandleLogout } from '../models/actions/HandleLogout';
|
import { HandleLogout } from '../models/actions/HandleLogout';
|
||||||
import { RefreshAuth } from '../models/actions/RefreshAuth';
|
import { RefreshAuth } from '../models/actions/RefreshAuth';
|
||||||
import { ResetPassword } from '../models/actions/ResetPassword';
|
import { ResetPassword } from '../models/actions/ResetPassword';
|
||||||
import { Auth } from '../models/responses/ResponseAuth';
|
import { ResponseAuth } from '../models/responses/ResponseAuth';
|
||||||
import { Logout } from '../models/responses/ResponseLogout';
|
import { Logout } from '../models/responses/ResponseLogout';
|
||||||
|
|
||||||
@JsonController('/auth')
|
@JsonController('/auth')
|
||||||
@ -16,7 +16,7 @@ export class AuthController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Post("/login")
|
@Post("/login")
|
||||||
@ResponseSchema(Auth)
|
@ResponseSchema(ResponseAuth)
|
||||||
@ResponseSchema(InvalidCredentialsError)
|
@ResponseSchema(InvalidCredentialsError)
|
||||||
@ResponseSchema(UserNotFoundError)
|
@ResponseSchema(UserNotFoundError)
|
||||||
@ResponseSchema(UsernameOrEmailNeededError)
|
@ResponseSchema(UsernameOrEmailNeededError)
|
||||||
@ -60,7 +60,7 @@ export class AuthController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Post("/refresh")
|
@Post("/refresh")
|
||||||
@ResponseSchema(Auth)
|
@ResponseSchema(ResponseAuth)
|
||||||
@ResponseSchema(JwtNotProvidedError)
|
@ResponseSchema(JwtNotProvidedError)
|
||||||
@ResponseSchema(IllegalJWTError)
|
@ResponseSchema(IllegalJWTError)
|
||||||
@ResponseSchema(UserNotFoundError)
|
@ResponseSchema(UserNotFoundError)
|
||||||
@ -82,7 +82,7 @@ export class AuthController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Post("/reset")
|
@Post("/reset")
|
||||||
@ResponseSchema(Auth)
|
@ResponseSchema(ResponseAuth)
|
||||||
@ResponseSchema(UserNotFoundError)
|
@ResponseSchema(UserNotFoundError)
|
||||||
@ResponseSchema(UsernameOrEmailNeededError)
|
@ResponseSchema(UsernameOrEmailNeededError)
|
||||||
@OpenAPI({ description: "Request a password reset token. <br> This will provide you with a reset token that you can use by posting to /api/auth/reset/{token}." })
|
@OpenAPI({ description: "Request a password reset token. <br> This will provide you with a reset token that you can use by posting to /api/auth/reset/{token}." })
|
||||||
@ -92,7 +92,7 @@ export class AuthController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Post("/reset/:token")
|
@Post("/reset/:token")
|
||||||
@ResponseSchema(Auth)
|
@ResponseSchema(ResponseAuth)
|
||||||
@ResponseSchema(UserNotFoundError)
|
@ResponseSchema(UserNotFoundError)
|
||||||
@ResponseSchema(UsernameOrEmailNeededError)
|
@ResponseSchema(UsernameOrEmailNeededError)
|
||||||
@OpenAPI({ description: "Reset a user's utilising a valid password reset token. <br> This will set the user's password to the one you provided in the body. <br> To get a reset token post to /api/auth/reset with your username." })
|
@OpenAPI({ description: "Reset a user's utilising a valid password reset token. <br> This will set the user's password to the one you provided in the body. <br> To get a reset token post to /api/auth/reset with your username." })
|
||||||
|
@ -5,7 +5,7 @@ import { config } from '../../config';
|
|||||||
import { IllegalJWTError, JwtNotProvidedError, RefreshTokenCountInvalidError, UserDisabledError, UserNotFoundError } from '../../errors/AuthError';
|
import { IllegalJWTError, JwtNotProvidedError, RefreshTokenCountInvalidError, UserDisabledError, UserNotFoundError } from '../../errors/AuthError';
|
||||||
import { JwtCreator } from "../../jwtcreator";
|
import { JwtCreator } from "../../jwtcreator";
|
||||||
import { User } from '../entities/User';
|
import { User } from '../entities/User';
|
||||||
import { Auth } from '../responses/ResponseAuth';
|
import { ResponseAuth } from '../responses/ResponseAuth';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is used to create refreshed auth credentials.
|
* This class is used to create refreshed auth credentials.
|
||||||
@ -24,8 +24,8 @@ export class RefreshAuth {
|
|||||||
/**
|
/**
|
||||||
* Creates a new auth object based on this.
|
* Creates a new auth object based on this.
|
||||||
*/
|
*/
|
||||||
public async toAuth(): Promise<Auth> {
|
public async toAuth(): Promise<ResponseAuth> {
|
||||||
let newAuth: Auth = new Auth();
|
let newAuth: ResponseAuth = new ResponseAuth();
|
||||||
if (!this.token || this.token === undefined) {
|
if (!this.token || this.token === undefined) {
|
||||||
throw new JwtNotProvidedError()
|
throw new JwtNotProvidedError()
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ import { InvalidCredentialsError, PasswordNeededError, UserDisabledError, UserNo
|
|||||||
import { UsernameOrEmailNeededError } from '../../../errors/UserErrors';
|
import { UsernameOrEmailNeededError } from '../../../errors/UserErrors';
|
||||||
import { JwtCreator } from '../../../jwtcreator';
|
import { JwtCreator } from '../../../jwtcreator';
|
||||||
import { User } from '../../entities/User';
|
import { User } from '../../entities/User';
|
||||||
import { Auth } from '../../responses/ResponseAuth';
|
import { ResponseAuth } from '../../responses/ResponseAuth';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is used to create auth credentials based on user credentials provided in a json body (post request).
|
* This class is used to create auth credentials based on user credentials provided in a json body (post request).
|
||||||
@ -42,8 +42,8 @@ export class CreateAuth {
|
|||||||
/**
|
/**
|
||||||
* Creates a new auth object based on this.
|
* Creates a new auth object based on this.
|
||||||
*/
|
*/
|
||||||
public async toAuth(): Promise<Auth> {
|
public async toAuth(): Promise<ResponseAuth> {
|
||||||
let newAuth: Auth = new Auth();
|
let newAuth: ResponseAuth = new ResponseAuth();
|
||||||
|
|
||||||
if (this.email === undefined && this.username === undefined) {
|
if (this.email === undefined && this.username === undefined) {
|
||||||
throw new UsernameOrEmailNeededError();
|
throw new UsernameOrEmailNeededError();
|
||||||
|
@ -3,7 +3,7 @@ import { IsInt, IsString } from 'class-validator';
|
|||||||
/**
|
/**
|
||||||
* Defines the repsonse auth.
|
* Defines the repsonse auth.
|
||||||
*/
|
*/
|
||||||
export class Auth {
|
export class ResponseAuth {
|
||||||
/**
|
/**
|
||||||
* The access_token - JWT shortterm access token.
|
* The access_token - JWT shortterm access token.
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user