aboutsummaryrefslogtreecommitdiff
path: root/pkg/database/sql/user.go
diff options
context:
space:
mode:
authorGabriel Arakaki Giovanini <mail@gabrielgio.me>2023-09-12 18:37:30 +0200
committerGabriel Arakaki Giovanini <mail@gabrielgio.me>2023-09-12 18:40:00 +0200
commitae10e121875982d6956d6bff453544cc59a75616 (patch)
tree9b6508c9b2a105ce3027bb24342916050e2f50cc /pkg/database/sql/user.go
parentd33ba9ee675eedf47ce4a7977d116bf81dda5b2e (diff)
downloadlens-ae10e121875982d6956d6bff453544cc59a75616.tar.gz
lens-ae10e121875982d6956d6bff453544cc59a75616.tar.bz2
lens-ae10e121875982d6956d6bff453544cc59a75616.zip
feat: Add admin control
Now only admins can access settings.
Diffstat (limited to 'pkg/database/sql/user.go')
-rw-r--r--pkg/database/sql/user.go18
1 files changed, 7 insertions, 11 deletions
diff --git a/pkg/database/sql/user.go b/pkg/database/sql/user.go
index 2ec8622..0c503c2 100644
--- a/pkg/database/sql/user.go
+++ b/pkg/database/sql/user.go
@@ -158,20 +158,16 @@ func (self *UserRepository) Create(ctx context.Context, createUser *repository.C
}
func (self *UserRepository) Update(ctx context.Context, id uint, update *repository.UpdateUser) error {
- user := &User{
- Model: gorm.Model{
- ID: id,
- },
- Username: update.Username,
- Name: update.Name,
- IsAdmin: update.IsAdmin,
- Path: update.Path,
- }
-
result := self.db.
WithContext(ctx).
+ Model(&User{}).
Omit("password").
- Updates(user)
+ Where("id = ?", id).
+ Update("username", update.Username).
+ Update("name", update.Name).
+ Update("is_admin", update.IsAdmin).
+ Update("path", update.Path)
+
if result.Error != nil {
return wrapError(result.Error)
}