2024-08-10 01:52:23 +00:00
|
|
|
package tokenservicelogic
|
2024-08-06 05:59:24 +00:00
|
|
|
|
|
|
|
type claims map[string]string
|
|
|
|
|
|
|
|
func (c claims) SetID(id string) {
|
|
|
|
c["id"] = id
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c claims) SetRole(role string) {
|
|
|
|
c["role"] = role
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c claims) SetDeviceID(deviceID string) {
|
|
|
|
c["device_id"] = deviceID
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c claims) SetScope(scope string) {
|
|
|
|
c["scope"] = scope
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c claims) Role() string {
|
|
|
|
role, ok := c["role"]
|
|
|
|
if !ok {
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
|
|
|
return role
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c claims) ID() string {
|
|
|
|
id, ok := c["id"]
|
|
|
|
if !ok {
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
|
|
|
return id
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c claims) DeviceID() string {
|
|
|
|
deviceID, ok := c["device_id"]
|
|
|
|
if !ok {
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
|
|
|
return deviceID
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c claims) UID() string {
|
|
|
|
uid, ok := c["uid"]
|
|
|
|
if !ok {
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
|
|
|
return uid
|
|
|
|
}
|