mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-11 13:16:53 +00:00
fix(BRIDGE-108): fixed GetInitials when empty username is passed; we now overwrite the username in the vault if its value changed, each time we refresh user auth
This commit is contained in:
@ -240,6 +240,10 @@ func (vault *Vault) GetOrAddUser(userID, username, primaryEmail, authUID, authRe
|
||||
return nil, false, err
|
||||
}
|
||||
|
||||
if err := user.updateUsernameUnsafe(username); err != nil {
|
||||
return nil, false, err
|
||||
}
|
||||
|
||||
return user, false, nil
|
||||
}
|
||||
}
|
||||
@ -450,6 +454,22 @@ func (vault *Vault) getUser(userID string) UserData {
|
||||
return users[idx]
|
||||
}
|
||||
|
||||
// getUserUnsafe - fetches the relevant UserData.
|
||||
// Should only be called from contexts in which the vault mutex has been read locked.
|
||||
func (vault *Vault) getUserUnsafe(userID string) UserData {
|
||||
users := vault.getUnsafe().Users
|
||||
|
||||
idx := xslices.IndexFunc(users, func(user UserData) bool {
|
||||
return user.UserID == userID
|
||||
})
|
||||
|
||||
if idx < 0 {
|
||||
panic("Unknown user")
|
||||
}
|
||||
|
||||
return users[idx]
|
||||
}
|
||||
|
||||
func (vault *Vault) modUser(userID string, fn func(userData *UserData)) error {
|
||||
vault.lock.Lock()
|
||||
defer vault.lock.Unlock()
|
||||
|
||||
Reference in New Issue
Block a user