48 lines
1.2 KiB
Go
48 lines
1.2 KiB
Go
package auth
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/golang-jwt/jwt/v5"
|
|
)
|
|
|
|
type Claims struct {
|
|
// ==================================================
|
|
// 🔑 IDENTITY
|
|
// ==================================================
|
|
ID int64 `json:"id"`
|
|
Username string `json:"username"`
|
|
RoleID int64 `json:"role_id"`
|
|
|
|
RoleCode string `json:"role_code"`
|
|
DepartmentCodes []string `json:"department_codes"`
|
|
|
|
// ==================================================
|
|
// 🧾 NEBIM (frontend filtre & backend guard için)
|
|
// ==================================================
|
|
V3Username string `json:"v3_username"`
|
|
V3UserGroup string `json:"v3_usergroup"`
|
|
|
|
// ==================================================
|
|
// 🔐 SESSION
|
|
// ==================================================
|
|
SessionID string `json:"session_id"`
|
|
|
|
// ==================================================
|
|
// ⚠️ SECURITY
|
|
// ==================================================
|
|
ForcePasswordChange bool `json:"force_password_change"`
|
|
|
|
jwt.RegisteredClaims
|
|
}
|
|
|
|
func (c *Claims) IsAdmin() bool {
|
|
if c == nil {
|
|
return false
|
|
}
|
|
|
|
role := strings.ToLower(strings.TrimSpace(c.RoleCode))
|
|
|
|
return role == "admin"
|
|
}
|