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

Method refreshUser

db/blip_handler.go:128–161  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

126}
127
128func (bh *blipHandler) refreshUser() error {
129
130 bc := bh.BlipSyncContext
131 if bc.userName != "" {
132 // Check whether user needs to be refreshed
133 bc.dbUserLock.Lock()
134 defer bc.dbUserLock.Unlock()
135 userChanged := bc.userChangeWaiter.RefreshUserCount()
136
137 // If changed, refresh the user and db while holding the lock
138 if userChanged {
139 // Refresh the BlipSyncContext database
140 err := bc.blipContextDb.ReloadUser(bh.loggingCtx)
141 if err != nil {
142 return base.NewHTTPError(CBLReconnectErrorCode, err.Error())
143 }
144 newUser := bc.blipContextDb.User()
145 err = newUser.InitializeRoles()
146 if err != nil {
147 return base.NewHTTPError(CBLReconnectErrorCode, err.Error())
148 }
149 bc.userChangeWaiter.RefreshUserKeys(newUser, bc.blipContextDb.MetadataKeys)
150 // refresh the handler's database with the new BlipSyncContext database
151 bh.db = bh._copyContextDatabase()
152 if bh.collection != nil {
153 bh.collection = &DatabaseCollectionWithUser{
154 DatabaseCollection: bh.collection.DatabaseCollection,
155 user: bh.db.User(),
156 }
157 }
158 }
159 }
160 return nil
161}
162
163// collectionBlipHandler wraps another blip handler to specify a collection
164func collectionBlipHandler(next blipHandlerFunc) blipHandlerFunc {

Callers 2

sendBatchOfChangesMethod · 0.95
userBlipHandlerFunction · 0.80

Calls 10

NewHTTPErrorFunction · 0.92
RefreshUserCountMethod · 0.80
RefreshUserKeysMethod · 0.80
_copyContextDatabaseMethod · 0.80
InitializeRolesMethod · 0.65
LockMethod · 0.45
UnlockMethod · 0.45
ReloadUserMethod · 0.45
ErrorMethod · 0.45
UserMethod · 0.45

Tested by

no test coverage detected