Make SuperUser functions more resiliant to nil values
This commit is contained in:
@@ -43,5 +43,5 @@ func NewSuperUserIdentity() *Identity {
|
||||
}
|
||||
|
||||
func IsSuperUser(i Identifiable) bool {
|
||||
return superUserID == i.Identity()
|
||||
return i != nil && superUserID == i.Identity()
|
||||
}
|
||||
|
||||
@@ -40,7 +40,10 @@ func SetSuperUserContext(ctx context.Context) context.Context {
|
||||
su := NewSuperUserIdentity()
|
||||
|
||||
ctx = SetIdentityToContext(ctx, su)
|
||||
ctx = SetJwtToContext(ctx, DefaultJwtHandler.Encode(su))
|
||||
|
||||
if DefaultJwtHandler != nil {
|
||||
ctx = SetJwtToContext(ctx, DefaultJwtHandler.Encode(su))
|
||||
}
|
||||
|
||||
return ctx
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user