You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Check if the service user ID is already in use for the same source type.
45
-
userDto.serviceUserId?.let { serviceUserId ->
46
-
val existingExternalUser = userRepository.findByExternalId(
47
-
externalId = serviceUserId,
48
-
sourceType = userDto.sourceType,
49
-
)
50
-
if (existingExternalUser !=null) {
51
-
val response =Response.status(Response.Status.CONFLICT)
52
-
.entity(mapOf("status" to 409, "message" to "Account with this service user ID $serviceUserId already exists for source type ${userDto.sourceType}.", "user" to userMapper.fromEntity(existingExternalUser)))
53
-
.build()
54
-
55
-
throwWebApplicationException(response)
56
-
}
57
-
}
58
-
59
46
val existingUser = userRepository.findByUserIdProjectIdSourceType(
// Check if the service user ID is already in use for the same source type but different user.
91
-
user.serviceUserId?.let { serviceUserId ->
92
-
val existingExternalUser = userRepository.findByExternalId(
93
-
externalId = serviceUserId,
94
-
sourceType = user.sourceType,
95
-
)
96
-
if (existingExternalUser !=null&& existingExternalUser.id != userId) {
97
-
val response =Response.status(Response.Status.CONFLICT)
98
-
.entity(mapOf("status" to 409, "message" to "Account with this service user ID $serviceUserId already exists for source type ${user.sourceType}.", "user" to userMapper.fromEntity(existingExternalUser)))
99
-
.build()
100
-
101
-
throwWebApplicationException(response)
102
-
}
103
-
}
104
-
105
77
return userMapper.fromEntity(
106
78
runLocked(userId) {
107
79
userRepository.update(userId, user)
@@ -139,6 +111,31 @@ class RestSourceUserService(
139
111
)
140
112
}
141
113
114
+
/**
115
+
* Validates that an external user ID is not already in use by another user.
116
+
* Should be called before updating a user's token with an external user ID.
0 commit comments