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)
| 141 | |
| 142 | // Creates a session with TTL and adds to the response. Does NOT return the session info response. |
| 143 | func (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. |
no test coverage detected