UserRights returns the rights the caller has on the given user.
(ctx context.Context, userIDs *ttnpb.UserIdentifiers)
| 197 | |
| 198 | // UserRights returns the rights the caller has on the given user. |
| 199 | func (is *IdentityServer) UserRights(ctx context.Context, userIDs *ttnpb.UserIdentifiers) (*ttnpb.Rights, error) { |
| 200 | entity, universal, err := is.getRights(ctx, userIDs.GetEntityIdentifiers()) |
| 201 | if err != nil { |
| 202 | return nil, err |
| 203 | } |
| 204 | err = is.store.Transact(ctx, func(ctx context.Context, st store.Store) error { |
| 205 | _, err := st.GetUser(ctx, userIDs, []string{"ids"}) |
| 206 | return err |
| 207 | }) |
| 208 | if errors.IsNotFound(err) { |
| 209 | if is.IsAdmin(ctx) { |
| 210 | return nil, err |
| 211 | } |
| 212 | return &ttnpb.Rights{}, nil |
| 213 | } else if err != nil { |
| 214 | return nil, err |
| 215 | } |
| 216 | return entity.Union(universal), nil |
| 217 | } |
| 218 | |
| 219 | var ( |
| 220 | errInsufficientRights = errors.DefinePermissionDenied( |
nothing calls this directly
no test coverage detected