backend/pkg/permission/usecase/token_claims.go

60 lines
833 B
Go
Raw Normal View History

2025-10-06 08:28:39 +00:00
package usecase
type tokenClaims map[string]string
func (tc tokenClaims) SetID(id string) {
tc["id"] = id
}
func (tc tokenClaims) SetRole(role string) {
tc["role"] = role
}
func (tc tokenClaims) SetDeviceID(deviceID string) {
tc["device_id"] = deviceID
}
func (tc tokenClaims) SetScope(scope string) {
tc["scope"] = scope
}
func (tc tokenClaims) SetAccount(account string) {
tc["account"] = account
}
func (tc tokenClaims) Role() string {
role, ok := tc["role"]
if !ok {
return ""
}
return role
}
func (tc tokenClaims) ID() string {
id, ok := tc["id"]
if !ok {
return ""
}
return id
}
func (tc tokenClaims) DeviceID() string {
deviceID, ok := tc["device_id"]
if !ok {
return ""
}
return deviceID
}
func (tc tokenClaims) UID() string {
uid, ok := tc["uid"]
if !ok {
return ""
}
return uid
}