Skip to content

Commit

Permalink
FIx order when validating account settings (#1632)
Browse files Browse the repository at this point in the history
* moved extraSettings validation to the end

* moved extraSettings validation directly after permission check
  • Loading branch information
pascal-fischer authored Feb 27, 2024
1 parent d78b652 commit b085419
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions management/server/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -917,12 +917,7 @@ func (am *DefaultAccountManager) UpdateAccountSettings(accountID, userID string,
unlock := am.Store.AcquireAccountLock(accountID)
defer unlock()

account, err := am.Store.GetAccountByUser(userID)
if err != nil {
return nil, err
}

err = additions.ValidateExtraSettings(newSettings.Extra, account.Settings.Extra, account.Peers, userID, accountID, am.eventStore)
account, err := am.Store.GetAccount(accountID)
if err != nil {
return nil, err
}
Expand All @@ -936,6 +931,11 @@ func (am *DefaultAccountManager) UpdateAccountSettings(accountID, userID string,
return nil, status.Errorf(status.PermissionDenied, "user is not allowed to update account")
}

err = additions.ValidateExtraSettings(newSettings.Extra, account.Settings.Extra, account.Peers, userID, accountID, am.eventStore)
if err != nil {
return nil, err
}

oldSettings := account.Settings
if oldSettings.PeerLoginExpirationEnabled != newSettings.PeerLoginExpirationEnabled {
event := activity.AccountPeerLoginExpirationEnabled
Expand Down

0 comments on commit b085419

Please sign in to comment.