backend db fixes
This commit is contained in:
@@ -60,6 +60,7 @@ func (ur *UserRepository) UpdateUser(user *models.User) (*models.User, error) {
|
||||
if err := tx.Preload(clause.Associations).
|
||||
Preload("Membership").
|
||||
Preload("Membership.SubscriptionModel").
|
||||
Preload("Licence").
|
||||
Preload("Licence.Categories").
|
||||
First(&existingUser, user.ID).Error; err != nil {
|
||||
return err
|
||||
@@ -88,6 +89,13 @@ func (ur *UserRepository) UpdateUser(user *models.User) (*models.User, error) {
|
||||
}
|
||||
}
|
||||
|
||||
// Replace categories if Licence and Categories are provided
|
||||
if user.Licence != nil {
|
||||
if err := tx.Model(&user.Licence).Association("Categories").Replace(user.Licence.Categories); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user