fix(auth): Cleanup getRefreshTokenCookiePath implementation
This commit is contained in:
parent
e8615efe8e
commit
fb0d0cb32c
|
|
@ -53,15 +53,17 @@ const RefreshTokenCookieName = "vikunja_refresh_token" //nolint:gosec // not a c
|
||||||
// getRefreshTokenCookiePath returns the cookie path for the refresh token,
|
// getRefreshTokenCookiePath returns the cookie path for the refresh token,
|
||||||
// derived from service.publicurl.
|
// derived from service.publicurl.
|
||||||
func getRefreshTokenCookiePath() string {
|
func getRefreshTokenCookiePath() string {
|
||||||
|
refreshURL := "/api/v1/user/token/refresh"
|
||||||
|
|
||||||
publicURL := config.ServicePublicURL.GetString()
|
publicURL := config.ServicePublicURL.GetString()
|
||||||
u, err := url.Parse(publicURL)
|
u, err := url.Parse(publicURL)
|
||||||
if err != nil || publicURL == "" || publicURL == "/" {
|
if err != nil {
|
||||||
return "/api/v1/user/token/refresh"
|
return refreshURL
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extract the path component and append the refresh endpoint
|
// Extract the path component and append the refresh endpoint
|
||||||
basePath := strings.TrimRight(u.Path, "/")
|
basePath := strings.TrimRight(u.Path, "/")
|
||||||
return basePath + "/api/v1/user/token/refresh"
|
return basePath + refreshURL
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetRefreshTokenCookie sets an HttpOnly cookie containing the refresh token.
|
// SetRefreshTokenCookie sets an HttpOnly cookie containing the refresh token.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue