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

Method makeSessionWithTTL

rest/session_api.go:143–157  ·  view source on GitHub ↗

Creates a session with TTL and adds to the response. Does NOT return the session info response.

(user auth.User, expiry time.Duration, oneTime bool)

Source from the content-addressed store, hash-verified

141
142// Creates a session with TTL and adds to the response. Does NOT return the session info response.
143func (h *handler) makeSessionWithTTL(user auth.User, expiry time.Duration, oneTime bool) (sessionID string, err error) {
144 if user == nil {
145 return "", ErrInvalidLogin
146 }
147 h.user = user
148 auth := h.db.Authenticator(h.ctx())
149 session, err := auth.CreateSession(h.ctx(), h.user, expiry, oneTime)
150 if err != nil {
151 return "", err
152 }
153 cookie := auth.MakeSessionCookie(session, h.db.Options.SecureCookieOverride, h.db.Options.SessionCookieHttpOnly, h.db.SameSiteCookieMode)
154 base.AddDbPathToCookie(h.rq, cookie)
155 http.SetCookie(h.response, cookie)
156 return session.ID, nil
157}
158
159// MakeSessionFromUserAndEmail first attempts to find the user by username. If found, updates the users's
160// email if different. If no match for username, attempts to find by the user by email.

Callers 3

handleSessionPOSTMethod · 0.95
makeSessionMethod · 0.95

Calls 5

ctxMethod · 0.95
AddDbPathToCookieFunction · 0.92
CreateSessionMethod · 0.80
MakeSessionCookieMethod · 0.80
AuthenticatorMethod · 0.45

Tested by

no test coverage detected