diff --git a/service/account/account.go b/service/account/account.go index 730fc8b..5e86dc6 100644 --- a/service/account/account.go +++ b/service/account/account.go @@ -97,22 +97,33 @@ func (s *AccountService) ChangeAvatarURL(id string, avatarURL string) error { return nil } -func (s *AccountService) Delete(accountID string) error { - return s.repo.Delete(accountID) +func (s *AccountService) Delete(id string) error { + if err := s.repo.Delete(id); err != nil { return err } + s.log.Printf("Deleted account %s", id) + return nil } -func (s *AccountService) IncrementFails(accountID string) (int, error) { - return s.repo.IncrementFails(accountID) +func (s *AccountService) IncrementFails(id string) (int, error) { + num, err := s.repo.IncrementFails(id) + if err != nil { return 0, err } + s.log.Printf("Incremented auth failures for account %s (now %d)", id, num) + return num, nil } -func (s *AccountService) ResetFails(accountID string) (error) { - return s.repo.ResetFails(accountID) +func (s *AccountService) ResetFails(id string) (error) { + if err := s.repo.ResetFails(id); err != nil { return err } + s.log.Printf("Reset auth failures for account %s", id) + return nil } -func (s *AccountService) Lock(accountID string) error { - return s.repo.Lock(accountID) +func (s *AccountService) Lock(id string) error { + if err := s.repo.Lock(id); err != nil { return err } + s.log.Printf("Locked account %s", id) + return nil } -func (s *AccountService) Unlock(accountID string) error { - return s.repo.Unlock(accountID) +func (s *AccountService) Unlock(id string) error { + if err := s.repo.Unlock(id); err != nil { return err } + s.log.Printf("Locked account %s", id) + return nil } diff --git a/service/account/account_test.go b/service/account/account_test.go index 6487d64..f12fdaf 100644 --- a/service/account/account_test.go +++ b/service/account/account_test.go @@ -2,7 +2,7 @@ package account import ( "arimelody-web/model" - accountRepo "arimelody-web/repository/account" + repository "arimelody-web/repository/account" "log" "os" "testing" @@ -18,7 +18,7 @@ func init() { if err != nil { panic(err) } defer devNullFile.Close() - repo := accountRepo.NewAccountRepositoryMemory() + repo := repository.NewAccountRepositoryMemory() service = NewAccountService( repo, log.New(devNullFile, "", model.DEFAULT_LOG_FLAGS),