feat: add update password
ci-api / test (push) Successful in 24m40s
ci-web / test (push) Canceled after 8m5s

This commit is contained in:
Nuxgrid
2026-07-29 14:18:14 +02:00
parent eda6c0e98a
commit 5a0c1bfe3f
5 changed files with 105 additions and 2 deletions
@@ -16,6 +16,7 @@ func NewGormStore(db *gorm.DB) *GormStore {
type Store interface {
UpdateUsername(id, newUsername string) (auth.User, error)
UpdatePassword(id, passwordHahs string) (auth.User, error)
}
func (s *GormStore) UpdateUsername(id, newUsername string) (auth.User, error) {
@@ -34,3 +35,15 @@ func (s *GormStore) UpdateUsername(id, newUsername string) (auth.User, error) {
return user, nil
}
func (s *GormStore) UpdatePassword(id, passwordHash string) (auth.User, error) {
result := s.db.Model(&auth.User{}).Where("id = ?", id).Update("password", passwordHash)
if result.Error != nil {
return auth.User{}, result.Error
}
var user auth.User
if err := s.db.First(&user, "id = ?", id).Error; err != nil {
return auth.User{}, err
}
return user, nil
}