feat(server): remove deprecated password field from update-me (#32623)

* feat(server): remove deprecated password field from update-me

* fix: tests for removed password field

(cherry picked from commit 3f6a071203187681b6c06b977665dc624c431336)
This commit is contained in:
bo0tzz
2026-10-22 05:25:45 +03:00
committed by Codex
parent ad9b368cb8
commit b3bd5d1fd1
8 changed files with 12 additions and 74 deletions
-5
View File
@@ -11,11 +11,6 @@ import { isoDatetimeToDate, sanitizeFilename, stringToBool, toEmail } from 'src/
export const UserUpdateMeSchema = z
.object({
email: toEmail.optional().describe('User email'),
password: z
.string()
.optional()
.describe('User password (deprecated, use change password endpoint)')
.meta({ deprecated: true }),
name: z.string().optional().describe('User name'),
avatarColor: UserAvatarColorSchema.nullish(),
})
-7
View File
@@ -3,7 +3,6 @@ import { Updateable } from 'kysely';
import { DateTime } from 'luxon';
import type { ArgOf } from 'src/repositories/event.repository.js';
import type { JobOf, UserMetadataItem } from 'src/types.js';
import { SALT_ROUNDS } from 'src/constants.js';
import { StorageCore } from 'src/cores/storage.core.js';
import { OnEvent, OnJob } from 'src/decorators.js';
import { AuthDto } from 'src/dtos/auth.dto.js';
@@ -68,12 +67,6 @@ export class UserService extends BaseService {
avatarColor: dto.avatarColor,
};
if (dto.password) {
const hashedPassword = await this.cryptoRepository.hashBcrypt(dto.password, SALT_ROUNDS);
update.password = hashedPassword;
update.shouldChangePassword = false;
}
const updatedUser = await this.userRepository.update(user.id, update);
return mapUserAdmin(updatedUser);
@@ -198,17 +198,6 @@ describe(UserService.name, () => {
await expect(sut.updateMe(auth, dto)).resolves.toMatchObject(dto);
await expect(sut.getMe(auth)).resolves.toMatchObject(dto);
});
it('should clear shouldChangePassword when the password is updated', async () => {
const { sut, ctx } = setup();
const { user } = await ctx.newUser({ shouldChangePassword: true });
const auth = factory.auth({ user: { id: user.id } });
await expect(sut.updateMe(auth, { password: 'super-secret' })).resolves.toMatchObject({
shouldChangePassword: false,
});
await expect(sut.getMe(auth)).resolves.toMatchObject({ shouldChangePassword: false });
});
});
describe('updateMyPreferences', () => {