ilk
This commit is contained in:
47
svc/auth/claims.go
Normal file
47
svc/auth/claims.go
Normal file
@@ -0,0 +1,47 @@
|
||||
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"
|
||||
}
|
||||
Reference in New Issue
Block a user