backend/pkg/permission/usecase/token_claims.go

78 lines
1.0 KiB
Go
Raw Normal View History

2025-10-06 08:28:39 +00:00
package usecase
2025-10-22 13:40:31 +00:00
type TokenClaims map[string]string
2025-10-06 08:28:39 +00:00
2025-10-22 13:40:31 +00:00
func (tc TokenClaims) SetID(id string) {
2025-10-06 08:28:39 +00:00
tc["id"] = id
}
2025-10-22 13:40:31 +00:00
func (tc TokenClaims) SetRole(role string) {
2025-10-06 08:28:39 +00:00
tc["role"] = role
}
2025-10-22 13:40:31 +00:00
func (tc TokenClaims) SetDeviceID(deviceID string) {
2025-10-06 08:28:39 +00:00
tc["device_id"] = deviceID
}
2025-10-22 13:40:31 +00:00
func (tc TokenClaims) SetScope(scope string) {
2025-10-06 08:28:39 +00:00
tc["scope"] = scope
}
2025-10-22 13:40:31 +00:00
func (tc TokenClaims) SetLoginID(loginID string) {
tc["login_id"] = loginID
2025-10-06 08:28:39 +00:00
}
2025-10-22 13:40:31 +00:00
func (tc TokenClaims) Role() string {
2025-10-06 08:28:39 +00:00
role, ok := tc["role"]
if !ok {
return ""
}
return role
}
2025-10-22 13:40:31 +00:00
func (tc TokenClaims) ID() string {
2025-10-06 08:28:39 +00:00
id, ok := tc["id"]
if !ok {
return ""
}
return id
}
2025-10-22 13:40:31 +00:00
func (tc TokenClaims) DeviceID() string {
2025-10-06 08:28:39 +00:00
deviceID, ok := tc["device_id"]
if !ok {
return ""
}
return deviceID
}
2025-10-22 13:40:31 +00:00
func (tc TokenClaims) UID() string {
2025-10-06 08:28:39 +00:00
uid, ok := tc["uid"]
if !ok {
return ""
}
return uid
}
2025-10-06 13:14:58 +00:00
2025-10-22 13:40:31 +00:00
func (tc TokenClaims) Scope() string {
2025-10-06 13:14:58 +00:00
scope, ok := tc["scope"]
if !ok {
return ""
}
return scope
}
2025-10-22 13:40:31 +00:00
func (tc TokenClaims) LoginID() string {
scope, ok := tc["login_id"]
2025-10-06 13:14:58 +00:00
if !ok {
return ""
}
return scope
}