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

Method AuthenticateOneTimeSession

auth/session.go:90–101  ·  view source on GitHub ↗

AuthenticateOneTimeSession authenticates a session and deletes it upon successful authentication if it was marked as a one time sesssion. If it is a one time session, delete the session.

(ctx context.Context, sessionID string)

Source from the content-addressed store, hash-verified

88// AuthenticateOneTimeSession authenticates a session and deletes it upon successful authentication if it was marked as
89// a one time sesssion. If it is a one time session, delete the session.
90func (auth *Authenticator) AuthenticateOneTimeSession(ctx context.Context, sessionID string) (User, error) {
91 session, user, err := auth.GetSession(sessionID)
92 if err != nil {
93 return nil, base.HTTPErrorf(http.StatusUnauthorized, "Session Invalid")
94 }
95
96 err = auth.deleteOneTimeSession(ctx, session)
97 if err != nil {
98 return nil, err
99 }
100 return user, nil
101}
102
103// deleteOneTimeSession deletes the session if it is marked as a one-time session. If the session can be not deleted, or
104// was already deleted an error is returned.

Callers 2

TestCreateOneTimeSessionFunction · 0.80
setUserForPublicAuthMethod · 0.80

Calls 3

GetSessionMethod · 0.95
deleteOneTimeSessionMethod · 0.95
HTTPErrorfFunction · 0.92

Tested by 1

TestCreateOneTimeSessionFunction · 0.64