From 051416276a96f854ff374feeceb79858d060a857 Mon Sep 17 00:00:00 2001 From: CURZOLA Pierre Date: Fri, 23 Feb 2024 15:36:09 +0100 Subject: [PATCH] fix(users): check before send update request if user is protected --- db/users/update.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/db/users/update.go b/db/users/update.go index d6456969..120f6aa6 100644 --- a/db/users/update.go +++ b/db/users/update.go @@ -47,6 +47,17 @@ func UpdateUser(ctx context.Context, app, addonUUID, username string) error { if !userExists { return errors.New(ctx, fmt.Sprintf("User \"%s\" does not exist", username)) } + // Check if the user is protected + var userIsProtected bool + for _, user := range l { + if user.Protected { + userIsProtected = true + break + } + } + if userIsProtected { + return errors.New(ctx, fmt.Sprintf("User \"%s\" is protected and cannot be updated", username)) + } password, confirmedPassword, err := askForPasswordWithRetry(ctx, 3) if err != nil {