mirror of
https://github.com/sct/overseerr.git
synced 2025-12-26 16:27:17 +01:00
fix(usersettings): exclude current user when checking for existing email (#1689)
This update modifies the user settings endpoint so that, when validating email uniqueness, the query excludes the current user’s own record (using id: Not(user.id))
This commit is contained in:
@@ -18,6 +18,7 @@ import { ApiError } from '@server/types/error';
|
||||
import { getHostname } from '@server/utils/getHostname';
|
||||
import { Router } from 'express';
|
||||
import net from 'net';
|
||||
import { Not } from 'typeorm';
|
||||
import { canMakePermissionsChange } from '.';
|
||||
|
||||
const isOwnProfile = (): Middleware => {
|
||||
@@ -125,8 +126,9 @@ userSettingsRoutes.post<
|
||||
}
|
||||
|
||||
const existingUser = await userRepository.findOne({
|
||||
where: { email: user.email },
|
||||
where: { email: user.email, id: Not(user.id) },
|
||||
});
|
||||
|
||||
if (oldEmail !== user.email && existingUser) {
|
||||
throw new ApiError(400, ApiErrorCode.InvalidEmail);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user