refactor: update default cookie path

This commit is contained in:
weloe
2023-06-09 03:01:48 +08:00
parent 2bf8ddfe57
commit ecef85c8af
2 changed files with 5 additions and 1 deletions

View File

@@ -11,7 +11,7 @@ type CookieConfig struct {
func DefaultCookieConfig() *CookieConfig {
return &CookieConfig{
Domain: "",
Path: "",
Path: "/",
Secure: false,
HttpOnly: false,
SameSite: "",

View File

@@ -71,6 +71,10 @@ func (e *Enforcer) responseToken(tokenValue string, loginModel *model.Login, ctx
}
}
if tokenConfig.CookieConfig.Path == "" {
tokenConfig.CookieConfig.Path = "/"
}
// add cookie use tokenConfig.CookieConfig
ctx.Response().AddCookie(tokenConfig.TokenName,
tokenValue,