mirror of
https://github.com/ngoduykhanh/wireguard-ui.git
synced 2025-04-19 19:59:13 +03:00
GetCookiePath util function
This commit is contained in:
parent
bee5c54127
commit
38e4f5cbec
4 changed files with 12 additions and 16 deletions
|
@ -98,10 +98,7 @@ func Login(db store.IStore) echo.HandlerFunc {
|
||||||
ageMax = 86400 * 7
|
ageMax = 86400 * 7
|
||||||
}
|
}
|
||||||
|
|
||||||
cookiePath := util.BasePath
|
cookiePath := util.GetCookiePath()
|
||||||
if cookiePath == "" {
|
|
||||||
cookiePath = "/"
|
|
||||||
}
|
|
||||||
|
|
||||||
sess, _ := session.Get("session", c)
|
sess, _ := session.Get("session", c)
|
||||||
sess.Options = &sessions.Options{
|
sess.Options = &sessions.Options{
|
||||||
|
|
|
@ -103,10 +103,7 @@ func doRefreshSession(c echo.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
cookiePath := util.BasePath
|
cookiePath := util.GetCookiePath()
|
||||||
if cookiePath == "" {
|
|
||||||
cookiePath = "/"
|
|
||||||
}
|
|
||||||
|
|
||||||
sess.Values["last_update"] = now
|
sess.Values["last_update"] = now
|
||||||
sess.Options = &sessions.Options{
|
sess.Options = &sessions.Options{
|
||||||
|
@ -217,10 +214,7 @@ func clearSession(c echo.Context) {
|
||||||
sess.Options.MaxAge = -1
|
sess.Options.MaxAge = -1
|
||||||
sess.Save(c.Request(), c.Response())
|
sess.Save(c.Request(), c.Response())
|
||||||
|
|
||||||
cookiePath := util.BasePath
|
cookiePath := util.GetCookiePath()
|
||||||
if cookiePath == "" {
|
|
||||||
cookiePath = "/"
|
|
||||||
}
|
|
||||||
|
|
||||||
cookie, err := c.Cookie("session_token")
|
cookie, err := c.Cookie("session_token")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -51,10 +51,7 @@ func (t *TemplateRegistry) Render(w io.Writer, name string, data interface{}, c
|
||||||
func New(tmplDir fs.FS, extraData map[string]interface{}, secret [64]byte) *echo.Echo {
|
func New(tmplDir fs.FS, extraData map[string]interface{}, secret [64]byte) *echo.Echo {
|
||||||
e := echo.New()
|
e := echo.New()
|
||||||
|
|
||||||
cookiePath := util.BasePath
|
cookiePath := util.GetCookiePath()
|
||||||
if cookiePath == "" {
|
|
||||||
cookiePath = "/"
|
|
||||||
}
|
|
||||||
|
|
||||||
cookieStore := sessions.NewCookieStore(secret[:32], secret[32:])
|
cookieStore := sessions.NewCookieStore(secret[:32], secret[32:])
|
||||||
cookieStore.Options.Path = cookiePath
|
cookieStore.Options.Path = cookiePath
|
||||||
|
|
|
@ -854,3 +854,11 @@ func ConcatMultipleSlices(slices ...[]byte) []byte {
|
||||||
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetCookiePath() string {
|
||||||
|
cookiePath := BasePath
|
||||||
|
if cookiePath == "" {
|
||||||
|
cookiePath = "/"
|
||||||
|
}
|
||||||
|
return cookiePath
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue