isolate web pages auth logic

This commit is contained in:
Viacheslav Evseev
2024-02-22 05:53:55 +03:00
parent 3695797f74
commit b50e5a381e
2 changed files with 14 additions and 8 deletions

View File

@@ -6,7 +6,6 @@ import (
"net/http"
"os"
"path/filepath"
"slices"
"unsafe"
"github.com/gin-gonic/gin"
@@ -69,15 +68,11 @@ func BasicAuth(accounts gin.Accounts) gin.HandlerFunc {
}
}
func CheckAuth(exclude ...string) gin.HandlerFunc {
func CheckAuth() gin.HandlerFunc {
return func(c *gin.Context) {
if !settings.HttpAuth {
return
}
if slices.Contains(exclude, c.FullPath()) {
return
}
if _, ok := c.Get(gin.AuthUserKey); ok {
return