mirror of
https://github.com/hanzoai/commerce.git
synced 2026-10-30 15:08:42 +00:00
Multi-tenant commerce and billing: orders, subscriptions, invoices, plans, usage metering and a credit ledger. One Go binary. MIT OR Apache-2.0. Claude-Session: https://claude.ai/code/session_01SAtaDFm8VDiWrhYHNNtxMw
30 lines
524 B
Go
30 lines
524 B
Go
package accesstoken
|
|
|
|
import (
|
|
"encoding/json"
|
|
|
|
"github.com/hanzoai/commerce/util/bit"
|
|
"github.com/hanzoai/commerce/util/jwt"
|
|
)
|
|
|
|
type Claims struct {
|
|
jwt.Claims
|
|
|
|
Name string `json:"name,omitempty"`
|
|
UserId string `json:"uid,omitempty"`
|
|
Permissions bit.Field `json:"bit,omitempty"`
|
|
}
|
|
|
|
func (c Claims) HasPermission(mask bit.Mask) bool {
|
|
return c.Permissions.Has(mask)
|
|
}
|
|
|
|
func (c Claims) Clone() jwt.Claimable {
|
|
return c
|
|
}
|
|
|
|
func (c Claims) JSON() string {
|
|
j, _ := json.Marshal(c)
|
|
return string(j)
|
|
}
|