refactor(server): narrow auth types (#16066)

This commit is contained in:
Jason Rasmussen
2025-02-12 15:23:08 -05:00
committed by GitHub
parent 7c821dd205
commit 2d7c333c8c
25 changed files with 265 additions and 239 deletions
+4 -6
View File
@@ -1,11 +1,9 @@
import { ApiProperty } from '@nestjs/swagger';
import { Transform } from 'class-transformer';
import { IsEmail, IsNotEmpty, IsString, MinLength } from 'class-validator';
import { SessionEntity } from 'src/entities/session.entity';
import { SharedLinkEntity } from 'src/entities/shared-link.entity';
import { AuthApiKey, AuthSession, AuthSharedLink, AuthUser } from 'src/database';
import { UserEntity } from 'src/entities/user.entity';
import { ImmichCookie } from 'src/enum';
import { AuthApiKey } from 'src/types';
import { toEmail } from 'src/validation';
export type CookieResponse = {
@@ -14,11 +12,11 @@ export type CookieResponse = {
};
export class AuthDto {
user!: UserEntity;
user!: AuthUser;
apiKey?: AuthApiKey;
sharedLink?: SharedLinkEntity;
session?: SessionEntity;
sharedLink?: AuthSharedLink;
session?: AuthSession;
}
export class LoginCredentialDto {
+1 -1
View File
@@ -47,7 +47,7 @@ export const mapUser = (entity: UserEntity): UserResponseDto => {
email: entity.email,
name: entity.name,
profileImagePath: entity.profileImagePath,
avatarColor: getPreferences(entity).avatar.color,
avatarColor: getPreferences(entity.email, entity.metadata || []).avatar.color,
profileChangedAt: entity.profileChangedAt,
};
};