implemented access token refreshing - untested
This commit is contained in:
+13
-8
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user