backend updateUser fix
This commit is contained in:
@@ -41,6 +41,29 @@ func (service *UserService) UpdateUser(user *models.User) (*models.User, error)
|
||||
setPassword(user.Password, user)
|
||||
}
|
||||
|
||||
// Validate subscription model
|
||||
selectedModel, err := repositories.GetModelByName(&user.Membership.SubscriptionModel.Name)
|
||||
if err != nil {
|
||||
return nil, errors.ErrSubscriptionNotFound
|
||||
}
|
||||
user.Membership.SubscriptionModel = *selectedModel
|
||||
user.Membership.SubscriptionModelID = selectedModel.ID
|
||||
|
||||
existingUser, err := service.GetUserByID(user.ID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
user.Membership.ID = existingUser.Membership.ID
|
||||
|
||||
user.MembershipID = existingUser.MembershipID
|
||||
if existingUser.Licence != nil {
|
||||
user.Licence.ID = existingUser.Licence.ID
|
||||
}
|
||||
user.LicenceID = existingUser.LicenceID
|
||||
user.BankAccount.ID = existingUser.BankAccount.ID
|
||||
user.BankAccountID = existingUser.BankAccountID
|
||||
|
||||
// if user.Licence.Status == 0 {
|
||||
// // This is a new drivers licence
|
||||
// user.Licence.Status = constants.UnverifiedStatus
|
||||
|
||||
Reference in New Issue
Block a user