* Working on some initial prototype stuff for TOTP * Fixed a bug that prevented the change password menu from working * Enable/disable totp working * Added the new login procedure including TOTP! :) * misc: Changed bad description for the TOTP_SECRET env var * I forgot to include the migration for the new prisma stuff * fix: refresh user context instead refreshing the page * refactor: simplify totp error handling * Removed U2F tab + format schema * fix: tokens not saved in cookies * refactor: deleted commented out code * refactor: move password text to input description * refactor: remove tabler icon package Co-authored-by: Elias Schneider <login@eliasschneider.com> Co-authored-by: Elias Schneider <58886915+stonith404@users.noreply.github.com>
38 lines
787 B
TypeScript
38 lines
787 B
TypeScript
import { Expose, plainToClass } from "class-transformer";
|
|
import { IsEmail, Length, Matches, MinLength } from "class-validator";
|
|
|
|
export class UserDTO {
|
|
@Expose()
|
|
id: string;
|
|
|
|
@Expose()
|
|
@Matches("^[a-zA-Z0-9_.]*$", undefined, {
|
|
message: "Username can only contain letters, numbers, dots and underscores",
|
|
})
|
|
@Length(3, 32)
|
|
username: string;
|
|
|
|
@Expose()
|
|
@IsEmail()
|
|
email: string;
|
|
|
|
@MinLength(8)
|
|
password: string;
|
|
|
|
@Expose()
|
|
isAdmin: boolean;
|
|
|
|
@Expose()
|
|
totpVerified: boolean;
|
|
|
|
from(partial: Partial<UserDTO>) {
|
|
return plainToClass(UserDTO, partial, { excludeExtraneousValues: true });
|
|
}
|
|
|
|
fromList(partial: Partial<UserDTO>[]) {
|
|
return partial.map((part) =>
|
|
plainToClass(UserDTO, part, { excludeExtraneousValues: true })
|
|
);
|
|
}
|
|
}
|