fix: replace first and last name with single field (#4915)
This commit is contained in:
@@ -33,8 +33,7 @@ export class LoginResponseDto {
|
||||
accessToken!: string;
|
||||
userId!: string;
|
||||
userEmail!: string;
|
||||
firstName!: string;
|
||||
lastName!: string;
|
||||
name!: string;
|
||||
profileImagePath!: string;
|
||||
isAdmin!: boolean;
|
||||
shouldChangePassword!: boolean;
|
||||
@@ -45,8 +44,7 @@ export function mapLoginResponse(entity: UserEntity, accessToken: string): Login
|
||||
accessToken: accessToken,
|
||||
userId: entity.id,
|
||||
userEmail: entity.email,
|
||||
firstName: entity.firstName,
|
||||
lastName: entity.lastName,
|
||||
name: entity.name,
|
||||
isAdmin: entity.isAdmin,
|
||||
profileImagePath: entity.profileImagePath,
|
||||
shouldChangePassword: entity.shouldChangePassword,
|
||||
@@ -62,12 +60,7 @@ export class SignUpDto extends LoginCredentialDto {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@ApiProperty({ example: 'Admin' })
|
||||
firstName!: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@ApiProperty({ example: 'Doe' })
|
||||
lastName!: string;
|
||||
name!: string;
|
||||
}
|
||||
|
||||
export class ChangePasswordDto {
|
||||
|
||||
@@ -236,7 +236,7 @@ describe('AuthService', () => {
|
||||
});
|
||||
|
||||
describe('adminSignUp', () => {
|
||||
const dto: SignUpDto = { email: 'test@immich.com', password: 'password', firstName: 'immich', lastName: 'admin' };
|
||||
const dto: SignUpDto = { email: 'test@immich.com', password: 'password', name: 'immich admin' };
|
||||
|
||||
it('should only allow one admin', async () => {
|
||||
userMock.getAdmin.mockResolvedValue({} as UserEntity);
|
||||
@@ -251,8 +251,7 @@ describe('AuthService', () => {
|
||||
id: 'admin',
|
||||
createdAt: new Date('2021-01-01'),
|
||||
email: 'test@immich.com',
|
||||
firstName: 'immich',
|
||||
lastName: 'admin',
|
||||
name: 'immich admin',
|
||||
});
|
||||
expect(userMock.getAdmin).toHaveBeenCalled();
|
||||
expect(userMock.create).toHaveBeenCalled();
|
||||
|
||||
@@ -146,8 +146,7 @@ export class AuthService {
|
||||
const admin = await this.userCore.createUser({
|
||||
isAdmin: true,
|
||||
email: dto.email,
|
||||
firstName: dto.firstName,
|
||||
lastName: dto.lastName,
|
||||
name: dto.name,
|
||||
password: dto.password,
|
||||
storageLabel: 'admin',
|
||||
});
|
||||
@@ -273,9 +272,9 @@ export class AuthService {
|
||||
storageLabel = null;
|
||||
}
|
||||
|
||||
const userName = profile.name ?? `${profile.given_name || ''} ${profile.family_name || ''}`;
|
||||
user = await this.userCore.createUser({
|
||||
firstName: profile.given_name || '',
|
||||
lastName: profile.family_name || '',
|
||||
name: userName,
|
||||
email: profile.email,
|
||||
oauthId: profile.sub,
|
||||
storageLabel,
|
||||
|
||||
Reference in New Issue
Block a user