further tidying up account service/repo
This commit is contained in:
parent
32bcb894ee
commit
9e311df462
4 changed files with 26 additions and 38 deletions
|
|
@ -81,7 +81,7 @@ func (s *AccountService) Create(
|
|||
|
||||
func (s *AccountService) ChangeUsername(id string, username string) error {
|
||||
if len(username) == 0 { return errors.New("Username cannot be empty") }
|
||||
if err := s.repo.ChangeUsername(id, username); err != nil {
|
||||
if err := s.repo.UpdateAvatarURL(id, username); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
@ -90,7 +90,7 @@ func (s *AccountService) ChangeUsername(id string, username string) error {
|
|||
}
|
||||
func (s *AccountService) ChangePassword(id string, password string) error {
|
||||
if len(password) == 0 { return errors.New("Password cannot be empty") }
|
||||
if err := s.repo.ChangePassword(id, password); err != nil {
|
||||
if err := s.repo.UpdateAvatarURL(id, password); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
@ -99,7 +99,7 @@ func (s *AccountService) ChangePassword(id string, password string) error {
|
|||
}
|
||||
func (s *AccountService) ChangeEmail(id string, email string) error {
|
||||
if len(email) == 0 { return s.repo.RemoveEmail(id) }
|
||||
if err := s.repo.ChangeEmail(id, email); err != nil {
|
||||
if err := s.repo.UpdateAvatarURL(id, email); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
@ -108,7 +108,7 @@ func (s *AccountService) ChangeEmail(id string, email string) error {
|
|||
}
|
||||
func (s *AccountService) ChangeAvatarURL(id string, avatarURL string) error {
|
||||
if len(avatarURL) == 0 { return s.repo.RemoveAvatar(id) }
|
||||
if err := s.repo.ChangeAvatarURL(id, avatarURL); err != nil {
|
||||
if err := s.repo.UpdateAvatarURL(id, avatarURL); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
@ -136,13 +136,13 @@ func (s *AccountService) ResetFails(id string) (error) {
|
|||
}
|
||||
|
||||
func (s *AccountService) Lock(id string) error {
|
||||
if err := s.repo.Lock(id); err != nil { return err }
|
||||
if err := s.repo.SetLocked(id, true); err != nil { return err }
|
||||
s.log.Printf("Locked account %s", id)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *AccountService) Unlock(id string) error {
|
||||
if err := s.repo.Unlock(id); err != nil { return err }
|
||||
s.log.Printf("Locked account %s", id)
|
||||
if err := s.repo.SetLocked(id, false); err != nil { return err }
|
||||
s.log.Printf("Unlocked account %s", id)
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue