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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *AccountService) Delete(accountID string) error {
|
func (s *AccountService) Delete(id string) error {
|
||||||
return s.repo.Delete(accountID)
|
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) {
|
func (s *AccountService) IncrementFails(id string) (int, error) {
|
||||||
return s.repo.IncrementFails(accountID)
|
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) {
|
func (s *AccountService) ResetFails(id string) (error) {
|
||||||
return s.repo.ResetFails(accountID)
|
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 {
|
func (s *AccountService) Lock(id string) error {
|
||||||
return s.repo.Lock(accountID)
|
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 {
|
func (s *AccountService) Unlock(id string) error {
|
||||||
return s.repo.Unlock(accountID)
|
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 (
|
import (
|
||||||
"arimelody-web/model"
|
"arimelody-web/model"
|
||||||
accountRepo "arimelody-web/repository/account"
|
repository "arimelody-web/repository/account"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
@ -18,7 +18,7 @@ func init() {
|
||||||
if err != nil { panic(err) }
|
if err != nil { panic(err) }
|
||||||
defer devNullFile.Close()
|
defer devNullFile.Close()
|
||||||
|
|
||||||
repo := accountRepo.NewAccountRepositoryMemory()
|
repo := repository.NewAccountRepositoryMemory()
|
||||||
service = NewAccountService(
|
service = NewAccountService(
|
||||||
repo,
|
repo,
|
||||||
log.New(devNullFile, "", model.DEFAULT_LOG_FLAGS),
|
log.New(devNullFile, "", model.DEFAULT_LOG_FLAGS),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue