Skip to content

Commit

Permalink
Use utlis function to void nil pointer panics
Browse files Browse the repository at this point in the history
Co-authored-by: kobergj <[email protected]>
  • Loading branch information
rhafer and kobergj authored May 24, 2022
1 parent 88ba401 commit 8bfda54
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions extensions/graph/pkg/middleware/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,8 @@ func Auth(opts ...account.Option) func(http.Handler) http.Handler {
ctx = revactx.ContextSetToken(ctx, t)
ctx = revactx.ContextSetUser(ctx, u)
ctx = gmmetadata.Set(ctx, opkgm.AccountID, u.Id.OpaqueId)
if u.Opaque != nil {
if roles, ok := u.Opaque.Map["roles"]; ok {
ctx = gmmetadata.Set(ctx, opkgm.RoleIDs, string(roles.Value))
}
if role := utils.ReadPlainFromOpaque(ctx, u.Opaque, "roles"); role != "" {
ctx = gmmetadata.Set(ctx, opkgm.RoleIDs, role)
}
ctx = metadata.AppendToOutgoingContext(ctx, revactx.TokenHeader, t)

Expand Down

0 comments on commit 8bfda54

Please sign in to comment.