satellite/console: pass entire auth.User into users.Update in service.UpdateAccount
The Update method of the usersDB takes a console.User as an argument. To update the columns in the DB, we have to migrate the fields from the console.Users struct into a special dbx struct. If one of these fields is left empty, then the zero value of that field's type will be used to update the respective column. In most cases where the users.Update method is called, the entire console.User is apparently retrieved first, fields are updated, then it is passed to users.Update. This is not the case for service.UpdateAccount. Because these fields are not populated in the user struct in UpdateAccount before it is passed into users.Update, their respective columns in the database are overwritten with zero: ProjectLimit, ProjectStorageLimit, ProjectBandwidthLimit, ProjectSegmentLimit, PaidTier, MfaEnabled, MfaRecoveryCodes, MfaSecretKey Solution: Do what is done in other places which call users.Update. Take the console.User from the auth context, update the relevant fields on that, then pass that in. Change-Id: I3cbd560e8ea5397e5c27711fb40bb3907d987028
This commit is contained in:
parent
0796653b07
commit
eefef2eb17
@ -950,14 +950,9 @@ func (s *Service) UpdateAccount(ctx context.Context, fullName string, shortName
|
|||||||
return ErrValidation.Wrap(err)
|
return ErrValidation.Wrap(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = s.store.Users().Update(ctx, &User{
|
auth.User.FullName = fullName
|
||||||
ID: auth.User.ID,
|
auth.User.ShortName = shortName
|
||||||
FullName: fullName,
|
err = s.store.Users().Update(ctx, &auth.User)
|
||||||
ShortName: shortName,
|
|
||||||
Email: auth.User.Email,
|
|
||||||
PasswordHash: nil,
|
|
||||||
Status: auth.User.Status,
|
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Error.Wrap(err)
|
return Error.Wrap(err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user