MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / UserRights

Method UserRights

pkg/identityserver/rights.go:199–217  ·  view source on GitHub ↗

UserRights returns the rights the caller has on the given user.

(ctx context.Context, userIDs *ttnpb.UserIdentifiers)

Source from the content-addressed store, hash-verified

197
198// UserRights returns the rights the caller has on the given user.
199func (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
219var (
220 errInsufficientRights = errors.DefinePermissionDenied(

Callers

nothing calls this directly

Implementers 5

mockInteroppkg/component/interop_test.go
interopServerpkg/joinserver/http_interop.go
noopServerpkg/interop/server.go
mockTargetpkg/interop/server_test.go
interopServerpkg/identityserver/http_interop.go

Calls 7

getRightsMethod · 0.95
IsAdminMethod · 0.95
IsNotFoundFunction · 0.92
UnionMethod · 0.80
GetEntityIdentifiersMethod · 0.65
TransactMethod · 0.65
GetUserMethod · 0.65

Tested by

no test coverage detected