MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / ComputeRolesForUser

Method ComputeRolesForUser

db/crud.go:3453–3471  ·  view source on GitHub ↗

Recomputes the set of channels a User/Role has been granted access to by sync() functions for a single collection.

(ctx context.Context, user auth.User)

Source from the content-addressed store, hash-verified

3451
3452// Recomputes the set of channels a User/Role has been granted access to by sync() functions for a single collection.
3453func (c *DatabaseCollection) ComputeRolesForUser(ctx context.Context, user auth.User) (channels.TimedSet, error) {
3454 results, err := c.QueryRoleAccess(ctx, user.Name())
3455 if err != nil {
3456 return nil, err
3457 }
3458
3459 // Merge the TimedSets from the view result:
3460 roleChannelSet := channels.TimedSet{}
3461 var roleAccessRow QueryAccessRow
3462 for results.Next(ctx, &roleAccessRow) {
3463 roleChannelSet.Add(roleAccessRow.Value)
3464 }
3465 closeErr := results.Close()
3466 if closeErr != nil {
3467 return nil, closeErr
3468 }
3469
3470 return roleChannelSet, nil
3471}
3472
3473// Checks whether a document has a mobile xattr. Used when running in non-xattr mode to support no downtime upgrade.
3474func (c *DatabaseCollection) checkForUpgrade(ctx context.Context, key string, unmarshalLevel DocumentUnmarshalLevel) (*Document, *sgbucket.BucketDocument) {

Callers

nothing calls this directly

Calls 5

QueryRoleAccessMethod · 0.95
AddMethod · 0.95
NameMethod · 0.65
CloseMethod · 0.65
NextMethod · 0.45

Tested by

no test coverage detected