account service: improve logging
This commit is contained in:
parent
fd3b2a0dba
commit
8bd1c556fb
2 changed files with 23 additions and 12 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue