save oauth user_id and link users and accounts

This commit is contained in:
2025-12-30 02:06:14 -07:00
parent bc592718bf
commit 8090a6f25e
21 changed files with 468 additions and 198 deletions
+7 -8
View File
@@ -48,20 +48,19 @@ func (s *Server) loginCallback(w http.ResponseWriter, r *http.Request) {
accessToken, expiration, err := s.auth.Exchange(ctx, q.Get("state"), q.Get("code"))
if err != nil {
http.Error(w, "Failed to exchange an authorization code for a token", http.StatusUnauthorized)
http.Error(w, fmt.Sprintf("Failed to exchange an authorization code for a token: %v", err), http.StatusUnauthorized)
return
}
// set access_token cookie and redirect to a reasonable place
w.Header().Set("Set-Cookie", (&http.Cookie{
Name: "access_token",
Value: accessToken,
Path: "/",
Expires: expiration,
MaxAge: 0, // using Expiration instead
Secure: true,
SameSite: http.SameSiteStrictMode,
Name: "access_token",
Value: accessToken,
Path: "/",
Expires: expiration,
MaxAge: 0, // using Expiration instead
Secure: true,
}).String())
http.Redirect(w, r, "/", http.StatusTemporaryRedirect)