mirror of
https://github.com/ngoduykhanh/wireguard-ui.git
synced 2025-06-07 00:46:58 +03:00
fix
This commit is contained in:
parent
73cd5ae94d
commit
1471c87886
1 changed files with 0 additions and 16 deletions
|
@ -23,22 +23,6 @@ func ValidSession(next echo.HandlerFunc) echo.HandlerFunc {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func ProtectedHandler(next echo.HandlerFunc) echo.HandlerFunc {
|
|
||||||
return func(c echo.Context) error {
|
|
||||||
sess, err := session.Get("session", c)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
apiKey, ok := sess.Values["api_key"].(string)
|
|
||||||
if !ok || apiKey != util.ApiKey {
|
|
||||||
return echo.NewHTTPError(http.StatusUnauthorized, "Invalid API key")
|
|
||||||
}
|
|
||||||
// Handle the request for authenticated users
|
|
||||||
return next(c)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func isValidSession(c echo.Context) bool {
|
func isValidSession(c echo.Context) bool {
|
||||||
if util.DisableLogin {
|
if util.DisableLogin {
|
||||||
return true
|
return true
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue