You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
OneAuth/libs/key/user.go

28 lines
502 B
Go

package key
import (
"github.com/veypi/OneAuth/cfg"
"github.com/veypi/utils"
"sync"
)
var keyCache = sync.Map{}
func User(uid uint, uuid string) string {
if uuid == cfg.CFG.APPUUID {
key, _ := keyCache.LoadOrStore(uid, utils.RandSeq(16))
return cfg.CFG.APPKey + key.(string)
}
// TODO: 获取其他应用user_key
return ""
}
func RefreshUser(uid uint, uuid string) string {
if uuid == cfg.CFG.APPUUID {
key := utils.RandSeq(16)
keyCache.Store(uid, key)
return key
}
return ""
}