This commit is contained in:
Nazar Kanaev
2021-03-19 00:06:48 +00:00
parent 391ce61362
commit 9f376db0f4
24 changed files with 65 additions and 67 deletions

View File

@@ -33,10 +33,10 @@ func Authenticate(rw http.ResponseWriter, username, password, basepath string) {
func Logout(rw http.ResponseWriter, basepath string) {
http.SetCookie(rw, &http.Cookie{
Name: "auth",
Value: "",
MaxAge: -1,
Path: basepath,
Name: "auth",
Value: "",
MaxAge: -1,
Path: basepath,
})
}

View File

@@ -20,7 +20,7 @@ func unsafeMethod(method string) bool {
}
func (m *Middleware) Handler(c *router.Context) {
if strings.HasPrefix(c.Req.URL.Path, m.BasePath + m.Public) {
if strings.HasPrefix(c.Req.URL.Path, m.BasePath+m.Public) {
c.Next()
return
}
@@ -46,7 +46,7 @@ func (m *Middleware) Handler(c *router.Context) {
} else {
c.HTML(http.StatusOK, assets.Template("login.html"), map[string]string{
"username": username,
"error": "Invalid username/password",
"error": "Invalid username/password",
})
return
}