Add callback and update user role
This commit is contained in:
@@ -15,6 +15,7 @@ type Context interface {
|
||||
IsSuperAdmin() bool
|
||||
IsCasheer() bool
|
||||
GetPartnerID() *int64
|
||||
GetSiteID() *int64
|
||||
}
|
||||
|
||||
type MyContextImpl struct {
|
||||
@@ -24,6 +25,7 @@ type MyContextImpl struct {
|
||||
requestID string
|
||||
partnerID int64
|
||||
roleID int
|
||||
siteID int64
|
||||
}
|
||||
|
||||
func (m *MyContextImpl) RequestedBy() int64 {
|
||||
@@ -45,12 +47,20 @@ func (m *MyContextImpl) GetPartnerID() *int64 {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MyContextImpl) GetSiteID() *int64 {
|
||||
if m.siteID != 0 {
|
||||
return &m.siteID
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewMyContext(parent context.Context, claims *entity.JWTAuthClaims) (*MyContextImpl, error) {
|
||||
return &MyContextImpl{
|
||||
Context: parent,
|
||||
requestedBy: claims.UserID,
|
||||
partnerID: claims.PartnerID,
|
||||
roleID: claims.Role,
|
||||
siteID: claims.SiteID,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user