mirror of
https://github.com/mainflux/mainflux.git
synced 2025-04-26 13:48:53 +08:00
NOISSUE - Fix listing (#1502)
Signed-off-by: Burak Sekili <buraksekili@gmail.com>
This commit is contained in:
parent
b78928c998
commit
87510288c2
@ -319,11 +319,19 @@ func (ts *thingsService) ListThings(ctx context.Context, token string, pm PageMe
|
||||
}
|
||||
|
||||
subject := res.GetId()
|
||||
// If the user is admin, fetch all things from database.
|
||||
if err := ts.authorize(ctx, res.GetId(), authoritiesObject, memberRelationKey); err == nil {
|
||||
subject = adminSubject
|
||||
pm.FetchSharedThings = true
|
||||
page, err := ts.things.RetrieveAll(ctx, res.GetEmail(), pm)
|
||||
if err != nil {
|
||||
return Page{}, err
|
||||
}
|
||||
return page, err
|
||||
// subject = adminSubject
|
||||
}
|
||||
|
||||
// If the user is not admin, check 'shared' parameter from pagemetada.
|
||||
// If user provides 'shared' key, fetch things from policies.
|
||||
if pm.FetchSharedThings {
|
||||
req := &mainflux.ListPoliciesReq{Act: "read", Sub: subject}
|
||||
lpr, err := ts.auth.ListPolicies(ctx, req)
|
||||
@ -338,6 +346,7 @@ func (ts *thingsService) ListThings(ctx context.Context, token string, pm PageMe
|
||||
return page, nil
|
||||
}
|
||||
|
||||
// By default, fetch things from Things service.
|
||||
page, err := ts.things.RetrieveAll(ctx, res.GetEmail(), pm)
|
||||
if err != nil {
|
||||
return Page{}, err
|
||||
|
Loading…
x
Reference in New Issue
Block a user