mirror of
https://github.com/weloe/token-go.git
synced 2025-10-12 19:01:39 +08:00
feat: support add token generate function
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package constant
|
||||
|
||||
// tokenStyle constant
|
||||
const (
|
||||
UUID = "uuid"
|
||||
SimpleUUID = "uuid-simple"
|
||||
|
@@ -445,6 +445,12 @@ func (e *Enforcer) GetRequestToken(ctx ctx.Context) string {
|
||||
return tokenValue
|
||||
}
|
||||
|
||||
// AddTokenGenerateFun add token generate strategy
|
||||
func (e *Enforcer) AddTokenGenerateFun(tokenStyle string, f model.GenerateFunc) error {
|
||||
e.generateFunc.AddFunc(tokenStyle, f)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e *Enforcer) GetSession(id string) *model.Session {
|
||||
if v := e.adapter.Get(e.spliceSessionKey(id)); v != nil {
|
||||
session := v.(*model.Session)
|
||||
|
@@ -23,6 +23,7 @@ type IEnforcer interface {
|
||||
Kickout(id string, device string) error
|
||||
|
||||
GetRequestToken(ctx ctx.Context) string
|
||||
AddTokenGenerateFun(tokenStyle string, f model.GenerateFunc) error
|
||||
|
||||
CheckLogin(ctx ctx.Context) error
|
||||
|
||||
|
Reference in New Issue
Block a user