chore: finish profile
This commit is contained in:
@@ -17,6 +17,8 @@ func NewGormStore(db *gorm.DB) *GormStore {
|
||||
type Store interface {
|
||||
UpdateUsername(id, newUsername string) (auth.User, error)
|
||||
UpdatePassword(id, passwordHahs string) (auth.User, error)
|
||||
GetTelegram(id string) (auth.User, error)
|
||||
SetTelegram(id, telegram string) (auth.User, error)
|
||||
}
|
||||
|
||||
func (s *GormStore) UpdateUsername(id, newUsername string) (auth.User, error) {
|
||||
@@ -36,8 +38,16 @@ 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)
|
||||
func (s *GormStore) GetTelegram(id string) (auth.User, error) {
|
||||
var user auth.User
|
||||
if err := s.db.First(&user, "id = ?", id).Error; err != nil {
|
||||
return auth.User{}, err
|
||||
}
|
||||
return user, nil
|
||||
}
|
||||
|
||||
func (s *GormStore) SetTelegram(id, telegram string) (auth.User, error) {
|
||||
result := s.db.Model(&auth.User{}).Where("id = ?", id).Update("telegram", telegram)
|
||||
if result.Error != nil {
|
||||
return auth.User{}, result.Error
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user