mirror of https://github.com/veypi/OneAuth.git
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.
28 lines
465 B
Go
28 lines
465 B
Go
package auth
|
|
|
|
import (
|
|
"OneAuth/models"
|
|
"github.com/veypi/utils"
|
|
"sync"
|
|
)
|
|
|
|
var keyCache = sync.Map{}
|
|
|
|
func GetUserKey(uid uint, app *models.App) string {
|
|
if app.ID == 1 {
|
|
key, _ := keyCache.LoadOrStore(uid, utils.RandSeq(16))
|
|
return key.(string)
|
|
}
|
|
// TODO: 获取其他应用user_key
|
|
return ""
|
|
}
|
|
|
|
func RefreshUserKey(uid uint, app *models.App) string {
|
|
if app.ID == 1 {
|
|
key := utils.RandSeq(16)
|
|
keyCache.Store(uid, key)
|
|
return key
|
|
}
|
|
return ""
|
|
}
|