Skip to content

Commit

Permalink
Use correct userId when updating user details (#655)
Browse files Browse the repository at this point in the history
  • Loading branch information
dominikriemer committed May 5, 2023
1 parent 2532e6a commit 0f84a55
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public Response deleteUser(@PathParam("principalId") String principalId) {
@PUT
@Produces(MediaType.APPLICATION_JSON)
public Response updateAppearanceMode(@PathParam("darkMode") boolean darkMode) {
String authenticatedUserId = getAuthenticatedUsername();
String authenticatedUserId = getAuthenticatedUserSid();
if (authenticatedUserId != null) {
UserAccount user = getUser(authenticatedUserId);
user.setDarkMode(darkMode);
Expand Down Expand Up @@ -199,7 +199,7 @@ public Response createNewApiToken(@PathParam("userId") String userId,
@Produces(MediaType.APPLICATION_JSON)
public Response updateUserAccountDetails(@PathParam("principalId") String principalId,
UserAccount user) {
String authenticatedUserId = getAuthenticatedUsername();
String authenticatedUserId = getAuthenticatedUserSid();
if (user != null && (authenticatedUserId.equals(principalId) || isAdmin())) {
UserAccount existingUser = (UserAccount) getPrincipalById(principalId);
updateUser(existingUser, user, isAdmin(), existingUser.getPassword());
Expand All @@ -217,7 +217,7 @@ public Response updateUserAccountDetails(@PathParam("principalId") String princi
@Produces(MediaType.APPLICATION_JSON)
public Response updateUsername(@PathParam("principalId") String principalId,
UserAccount user) {
String authenticatedUserId = getAuthenticatedUsername();
String authenticatedUserId = getAuthenticatedUserSid();
if (user != null && (authenticatedUserId.equals(principalId) || isAdmin())) {
UserAccount existingUser = (UserAccount) getPrincipalById(principalId);
try {
Expand Down Expand Up @@ -279,7 +279,7 @@ public Response updatePassword(@PathParam("principalId") String principalId,
@Produces(MediaType.APPLICATION_JSON)
public Response updateServiceAccountDetails(@PathParam("principalId") String principalId,
ServiceAccount user) {
String authenticatedUserId = getAuthenticatedUsername();
String authenticatedUserId = getAuthenticatedUserSid();
if (user != null && (authenticatedUserId.equals(principalId) || isAdmin())) {
Principal existingUser = getPrincipalById(principalId);
user.setRev(existingUser.getRev());
Expand Down

0 comments on commit 0f84a55

Please sign in to comment.