113 lines
2.5 KiB
TypeScript
113 lines
2.5 KiB
TypeScript
import { ApiProperty } from '@nestjs/swagger';
|
|
import { IsEmail, IsString, MinLength, IsIn, IsOptional } from 'class-validator';
|
|
|
|
export class AuthenticatedUserDTO {
|
|
@ApiProperty()
|
|
userId!: string;
|
|
@ApiProperty()
|
|
email!: string;
|
|
@ApiProperty()
|
|
displayName!: string;
|
|
@ApiProperty({ required: false })
|
|
primaryDriverId?: string;
|
|
@ApiProperty({ required: false, nullable: true })
|
|
avatarUrl?: string | null;
|
|
@ApiProperty({ required: false, enum: ['driver', 'sponsor', 'league-owner', 'league-steward', 'league-admin', 'system-owner', 'super-admin'] })
|
|
role?: 'driver' | 'sponsor' | 'league-owner' | 'league-steward' | 'league-admin' | 'system-owner' | 'super-admin';
|
|
}
|
|
|
|
export class AuthSessionDTO {
|
|
@ApiProperty()
|
|
token!: string;
|
|
@ApiProperty()
|
|
user!: AuthenticatedUserDTO;
|
|
}
|
|
|
|
export class SignupParamsDTO {
|
|
@ApiProperty()
|
|
@IsEmail()
|
|
email!: string;
|
|
|
|
@ApiProperty()
|
|
@IsString()
|
|
@MinLength(8)
|
|
password!: string;
|
|
|
|
@ApiProperty()
|
|
@IsString()
|
|
@MinLength(2)
|
|
displayName!: string;
|
|
|
|
@ApiProperty({ required: false })
|
|
iracingCustomerId?: string;
|
|
|
|
@ApiProperty({ required: false })
|
|
primaryDriverId?: string;
|
|
|
|
@ApiProperty({ required: false, nullable: true })
|
|
avatarUrl?: string | null;
|
|
}
|
|
|
|
export class LoginParamsDTO {
|
|
@ApiProperty()
|
|
@IsEmail()
|
|
email!: string;
|
|
|
|
@ApiProperty()
|
|
@IsString()
|
|
password!: string;
|
|
|
|
@ApiProperty({ required: false, default: false })
|
|
@IsOptional()
|
|
rememberMe?: boolean;
|
|
}
|
|
|
|
export class IracingAuthRedirectResultDTO {
|
|
@ApiProperty()
|
|
redirectUrl!: string;
|
|
@ApiProperty()
|
|
state!: string;
|
|
}
|
|
|
|
export class LoginWithIracingCallbackParamsDTO {
|
|
@ApiProperty()
|
|
@IsString()
|
|
code!: string;
|
|
|
|
@ApiProperty()
|
|
@IsString()
|
|
state!: string;
|
|
|
|
@ApiProperty({ required: false })
|
|
@IsString()
|
|
returnTo?: string;
|
|
}
|
|
|
|
export class ForgotPasswordDTO {
|
|
@ApiProperty()
|
|
@IsEmail()
|
|
email!: string;
|
|
}
|
|
|
|
export class ResetPasswordDTO {
|
|
@ApiProperty()
|
|
@IsString()
|
|
token!: string;
|
|
|
|
@ApiProperty()
|
|
@IsString()
|
|
@MinLength(8)
|
|
newPassword!: string;
|
|
}
|
|
|
|
export class DemoLoginDTO {
|
|
@ApiProperty({ enum: ['driver', 'sponsor', 'league-owner', 'league-steward', 'league-admin', 'system-owner', 'super-admin'] })
|
|
@IsString()
|
|
@IsIn(['driver', 'sponsor', 'league-owner', 'league-steward', 'league-admin', 'system-owner', 'super-admin'])
|
|
role!: 'driver' | 'sponsor' | 'league-owner' | 'league-steward' | 'league-admin' | 'system-owner' | 'super-admin';
|
|
|
|
@ApiProperty({ required: false, default: false })
|
|
@IsOptional()
|
|
rememberMe?: boolean;
|
|
}
|