mirror of
https://github.com/immich-app/immich.git
synced 2025-01-04 02:46:47 +01:00
fix(server) Cannot change first time password due to null in first and last name payload (#1205)
* fix(server) Cannot change first time password due to null in first and last name payload * Added error message for form on the web
This commit is contained in:
parent
7810dd1942
commit
1eb9ac8217
2 changed files with 43 additions and 13 deletions
|
@ -35,11 +35,25 @@ export class UserCore {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const user = await this.userRepository.get(id);
|
||||||
|
if (!user) {
|
||||||
|
throw new NotFoundException('User not found');
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (dto.password) {
|
if (dto.password) {
|
||||||
dto.password = await hash(dto.password, SALT_ROUNDS);
|
dto.password = await hash(dto.password, SALT_ROUNDS);
|
||||||
}
|
}
|
||||||
return this.userRepository.update(id, dto);
|
|
||||||
|
user.password = dto.password ?? user.password;
|
||||||
|
user.email = dto.email ?? user.email;
|
||||||
|
user.firstName = dto.firstName ?? user.firstName;
|
||||||
|
user.lastName = dto.lastName ?? user.lastName;
|
||||||
|
user.isAdmin = dto.isAdmin ?? user.isAdmin;
|
||||||
|
user.shouldChangePassword = dto.shouldChangePassword ?? user.shouldChangePassword;
|
||||||
|
user.profileImagePath = dto.profileImagePath ?? user.profileImagePath;
|
||||||
|
|
||||||
|
return this.userRepository.update(id, user);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
Logger.error(e, 'Failed to update user info');
|
Logger.error(e, 'Failed to update user info');
|
||||||
throw new InternalServerErrorException('Failed to update user info');
|
throw new InternalServerErrorException('Failed to update user info');
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { api } from '@api';
|
import { api } from '@api';
|
||||||
import { createEventDispatcher } from 'svelte';
|
import { createEventDispatcher } from 'svelte';
|
||||||
|
import {
|
||||||
|
notificationController,
|
||||||
|
NotificationType
|
||||||
|
} from '../shared-components/notification/notification';
|
||||||
|
|
||||||
let error: string;
|
let error: string;
|
||||||
let success: string;
|
let success: string;
|
||||||
|
@ -38,6 +42,7 @@
|
||||||
const firstName = form.get('firstName');
|
const firstName = form.get('firstName');
|
||||||
const lastName = form.get('lastName');
|
const lastName = form.get('lastName');
|
||||||
|
|
||||||
|
try {
|
||||||
const { status } = await api.userApi.createUser({
|
const { status } = await api.userApi.createUser({
|
||||||
email: String(email),
|
email: String(email),
|
||||||
password: String(password),
|
password: String(password),
|
||||||
|
@ -56,6 +61,17 @@
|
||||||
error = 'Error create user account';
|
error = 'Error create user account';
|
||||||
isCreatingUser = false;
|
isCreatingUser = false;
|
||||||
}
|
}
|
||||||
|
} catch (e) {
|
||||||
|
error = 'Error create user account';
|
||||||
|
isCreatingUser = false;
|
||||||
|
|
||||||
|
console.log('[ERROR] registerUser', e);
|
||||||
|
|
||||||
|
notificationController.show({
|
||||||
|
message: `Error create new user, check console for more detail`,
|
||||||
|
type: NotificationType.Error
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in a new issue