feat: add login logout feature and test

This commit is contained in:
weloe
2023-05-06 02:54:48 +08:00
parent 17700abd8a
commit cabebd0563
7 changed files with 1064 additions and 22 deletions

38
enforcer_interface.go Normal file
View File

@@ -0,0 +1,38 @@
package token_go
import (
"github.com/weloe/token-go/ctx"
"github.com/weloe/token-go/log"
"github.com/weloe/token-go/model"
"github.com/weloe/token-go/persist"
)
var _ IEnforcer = &Enforcer{}
type IEnforcer interface {
Login(id string) (string, error)
LoginByModel(id string, loginModel *model.Login) (string, error)
Logout() error
IsLogin() (bool, error)
IsLoginById(id string) (bool, error)
GetLoginId() (string, error)
Replaced(id string, device string) error
// Banned TODO
Banned(id string, service string) error
Kickout(id string, device string) error
GetRequestToken() string
SetType(t string)
GetType() string
SetContext(ctx ctx.Context)
GetAdapter() persist.Adapter
SetAdapter(adapter persist.Adapter)
SetWatcher(watcher persist.Watcher)
SetLogger(logger log.Logger)
EnableLog()
IsLogEnable() bool
GetSession(id string) *model.Session
SetSession(id string, session *model.Session, timeout int64) error
}