fee314870d
- Change JWT access token RoleID claim from int to []int to support multiple roles per user - Update all token generation and refresh logic to handle multiple role IDs as []int - Refactor services to return and process multiple role IDs from user_roles table - Fix OAuth state handling explanation and improve code comments - Clean up related function signatures and usages for consistency
35 lines
999 B
Go
35 lines
999 B
Go
package models
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/golang-jwt/jwt/v5"
|
|
)
|
|
|
|
type AccessToken struct {
|
|
Email string `json:"email"`
|
|
UsersID string `json:"users_id"`
|
|
RoleID []int `json:"role_id"`
|
|
SessionID string `json:"session_id"`
|
|
Exp int64 `json:"exp"`
|
|
jwt.RegisteredClaims
|
|
}
|
|
|
|
type JWTSession struct {
|
|
ID string `json:"id" db:"id"`
|
|
UsersID string `json:"users_id" db:"users_id"`
|
|
RefreshTokenHash string `json:"refresh_token_hash" db:"refresh_token_hash"`
|
|
UserAgent string `json:"user_agent" db:"user_agent"`
|
|
IPAddress string `json:"ip_address" db:"ip_address"`
|
|
CreatedAt time.Time `json:"created_at" db:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
|
|
ExpiresAt time.Time `json:"expires_at" db:"expires_at"`
|
|
IsRevoked bool `json:"is_revoked" db:"is_revoked"`
|
|
}
|
|
|
|
type ExpiredSession struct {
|
|
ID string
|
|
UsersID string
|
|
RefreshTokenHash string
|
|
}
|