AuthenticateRequest extracts the user from the session cookie. Returns nil if not authenticated.
(r *http.Request)
| 517 | |
| 518 | // AuthenticateRequest extracts the user from the session cookie. Returns nil if not authenticated. |
| 519 | func (ua *UserAuth) AuthenticateRequest(r *http.Request) *identity.User { |
| 520 | cookie, err := r.Cookie(SessionCookieName) |
| 521 | if err != nil { |
| 522 | return nil |
| 523 | } |
| 524 | user, err := ua.store.GetUserSession(r.Context(), cookie.Value) |
| 525 | if err != nil { |
| 526 | return nil |
| 527 | } |
| 528 | return user |
| 529 | } |
| 530 | |
| 531 | type googleUserInfo struct { |
| 532 | Sub string `json:"sub"` |
no test coverage detected