move auth related models into auth package
This commit is contained in:
parent
2a9667a616
commit
6b7b5f2ae9
12 changed files with 159 additions and 151 deletions
|
|
@ -1,61 +0,0 @@
|
|||
package mock
|
||||
|
||||
import "github.com/dhax/go-base/models"
|
||||
|
||||
type AuthStore struct {
|
||||
GetByIDFn func(id int) (*models.Account, error)
|
||||
GetByIDInvoked bool
|
||||
|
||||
GetByEmailFn func(email string) (*models.Account, error)
|
||||
GetByEmailInvoked bool
|
||||
|
||||
GetByRefreshTokenFn func(token string) (*models.Account, *models.Token, error)
|
||||
GetByRefreshTokenInvoked bool
|
||||
|
||||
UpdateAccountFn func(a *models.Account) error
|
||||
UpdateAccountInvoked bool
|
||||
|
||||
SaveRefreshTokenFn func(u *models.Token) error
|
||||
SaveRefreshTokenInvoked bool
|
||||
|
||||
DeleteRefreshTokenFn func(t *models.Token) error
|
||||
DeleteRefreshTokenInvoked bool
|
||||
|
||||
PurgeExpiredTokenFn func() error
|
||||
PurgeExpiredTokenInvoked bool
|
||||
}
|
||||
|
||||
func (s *AuthStore) GetByID(id int) (*models.Account, error) {
|
||||
s.GetByIDInvoked = true
|
||||
return s.GetByIDFn(id)
|
||||
}
|
||||
|
||||
func (s *AuthStore) GetByEmail(email string) (*models.Account, error) {
|
||||
s.GetByEmailInvoked = true
|
||||
return s.GetByEmailFn(email)
|
||||
}
|
||||
|
||||
func (s *AuthStore) GetByRefreshToken(token string) (*models.Account, *models.Token, error) {
|
||||
s.GetByRefreshTokenInvoked = true
|
||||
return s.GetByRefreshTokenFn(token)
|
||||
}
|
||||
|
||||
func (s *AuthStore) UpdateAccount(a *models.Account) error {
|
||||
s.UpdateAccountInvoked = true
|
||||
return s.UpdateAccountFn(a)
|
||||
}
|
||||
|
||||
func (s *AuthStore) SaveRefreshToken(u *models.Token) error {
|
||||
s.SaveRefreshTokenInvoked = true
|
||||
return s.SaveRefreshTokenFn(u)
|
||||
}
|
||||
|
||||
func (s *AuthStore) DeleteRefreshToken(t *models.Token) error {
|
||||
s.DeleteRefreshTokenInvoked = true
|
||||
return s.DeleteRefreshTokenFn(t)
|
||||
}
|
||||
|
||||
func (s *AuthStore) PurgeExpiredToken() error {
|
||||
s.PurgeExpiredTokenInvoked = true
|
||||
return s.PurgeExpiredTokenFn()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue