fileserver/dto/src/responses/auth.ts

39 lines
957 B
TypeScript
Raw Normal View History

2022-08-25 12:16:29 +00:00
import { SuccessResponse } from './base';
2022-08-25 11:39:58 +00:00
import { IsBase32, IsJWT, IsNotEmpty } from 'class-validator';
2022-08-25 13:13:44 +00:00
import { ValidateConstructor } from '../utils';
2022-08-25 13:13:44 +00:00
@ValidateConstructor
2022-08-25 12:16:29 +00:00
export class LoginResponse extends SuccessResponse {
2022-08-25 13:13:44 +00:00
constructor(jwt: string) {
super();
this.jwt = jwt;
}
2022-08-25 11:39:58 +00:00
@IsNotEmpty()
@IsJWT()
jwt: string;
}
2022-08-25 13:13:44 +00:00
@ValidateConstructor
2022-08-25 12:16:29 +00:00
export class RequestTotpTfaResponse extends SuccessResponse {
2022-08-25 13:13:44 +00:00
constructor(qrCode: string, secret: string) {
super();
this.qrCode = qrCode;
this.secret = secret;
}
2022-08-25 11:39:58 +00:00
@IsNotEmpty()
qrCode: string;
2022-08-25 11:39:58 +00:00
@IsNotEmpty()
@IsBase32()
secret: string;
}
2022-08-25 13:13:44 +00:00
export class TfaRequiredResponse extends SuccessResponse {}
export class RemoveTfaResponse extends SuccessResponse {}
export class RequestEmailTfaResponse extends SuccessResponse {}
export class TfaCompletedResponse extends SuccessResponse {}
export class SignupResponse extends SuccessResponse {}
export class RefreshResponse extends LoginResponse {}