fix(user): replace 'user' type with 'visitor' in user creation
refactor(session): improve token expiration handling in GetTokenInfo chore: add /dist to gitignore
This commit is contained in:
+11
-3
@@ -121,14 +121,22 @@ func RemoveToken(userID int) {
|
||||
|
||||
func GetTokenInfo(userID int) (*TokenInfo, error) {
|
||||
tokenMux.RLock()
|
||||
defer tokenMux.RUnlock()
|
||||
|
||||
tokenInfo, exists := tokenMap[userID]
|
||||
if !exists {
|
||||
tokenMux.RUnlock()
|
||||
return nil, fmt.Errorf("Token not found for userID %d", userID)
|
||||
|
||||
}
|
||||
|
||||
if time.Since(tokenInfo.CreatedAt) > tokenTTL {
|
||||
tokenMux.RUnlock()
|
||||
tokenMux.Lock()
|
||||
delete(tokenMap, userID)
|
||||
tokenMux.Unlock()
|
||||
postLog.Debug(fmt.Sprintf("[GetTokenInfo] Removed expired token for userID %d during login check", userID))
|
||||
return nil, fmt.Errorf("Token expired for userID %d", userID)
|
||||
}
|
||||
tokenMux.RUnlock()
|
||||
|
||||
return tokenInfo, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user