feat(wip): site category

This commit is contained in:
Jacky 2024-10-24 23:09:16 +08:00
parent ed3c02fc6f
commit 7ad5cac3b8
No known key found for this signature in database
GPG key ID: 215C21B10DF38B4D
73 changed files with 713 additions and 235 deletions

View file

@ -46,16 +46,16 @@ func secureSessionIDCacheKey(sessionId string) string {
return fmt.Sprintf("2fa_secure_session:_%s", sessionId)
}
func SetSecureSessionID(userId int) (sessionId string) {
func SetSecureSessionID(userId uint64) (sessionId string) {
sessionId = uuid.NewString()
cache.Set(secureSessionIDCacheKey(sessionId), userId, 5*time.Minute)
return
}
func VerifySecureSessionID(sessionId string, userId int) bool {
func VerifySecureSessionID(sessionId string, userId uint64) bool {
if v, ok := cache.Get(secureSessionIDCacheKey(sessionId)); ok {
if v.(int) == userId {
if v.(uint64) == userId {
return true
}
}

View file

@ -15,7 +15,7 @@ const ExpiredTime = 24 * time.Hour
type JWTClaims struct {
Name string `json:"name"`
UserID int `json:"user_id"`
UserID uint64 `json:"user_id"`
jwt.RegisteredClaims
}