implemented access token refreshing - untested

This commit is contained in:
2026-01-04 21:34:24 -07:00
parent e36c759dc2
commit 8ccc795812
5 changed files with 221 additions and 23 deletions
+13 -8
View File
@@ -4,6 +4,7 @@ import (
"fmt"
"net/http"
"ruben/inventory2/internal/site/response"
"time"
)
// GET /login
@@ -53,14 +54,18 @@ func (s *Server) loginCallback(r *http.Request) (response.Response, error) {
// set access_token cookie and redirect to a reasonable place
return response.TemporaryRedirect("/").
Cookie(http.Cookie{
Name: "access_token",
Value: accessToken,
Path: "/",
Expires: expiration,
MaxAge: 0, // using Expiration instead
Secure: true,
}), nil
Cookie(newAccessTokenCookie(accessToken, expiration)), nil
}
func newAccessTokenCookie(tkn string, expiration time.Time) http.Cookie {
return http.Cookie{
Name: "access_token",
Value: tkn,
Path: "/",
Expires: expiration,
MaxAge: 0, // using Expiration instead
Secure: true,
}
}
// GET /logout