develop #6

Merged
zeni merged 4 commits from develop into main 2024-10-28 13:21:42 -04:00
3 changed files with 26 additions and 2 deletions
Showing only changes of commit 91455fc972 - Show all commits

1
.gitignore vendored
View file

@ -6,3 +6,4 @@ logs/*
tls/*
!tls/.gitkeep
.DS_Store
storage/sqlite/*

View file

@ -425,8 +425,28 @@ func SetNewPassword(c *core.Context) *core.Response {
}
func Signout(c *core.Context) *core.Response {
// check if template engine is enable
TemplateEnableStr := os.Getenv("TEMPLATE_ENABLE")
if TemplateEnableStr == "" {
TemplateEnableStr = "false"
}
TemplateEnable, _ := strconv.ParseBool(TemplateEnableStr)
token := ""
if TemplateEnable {
// get cookie
usercookie, err := c.GetCookie()
if err != nil {
}
token = usercookie.Token
} else {
tokenRaw := c.GetHeader("Authorization")
token := strings.TrimSpace(strings.Replace(tokenRaw, "Bearer", "", 1))
token = strings.TrimSpace(strings.Replace(tokenRaw, "Bearer", "", 1))
}
if token == "" {
return c.Response.SetStatusCode(http.StatusUnauthorized).Json(c.MapToJson(map[string]interface{}{
"message": "unauthorized",

View file

@ -36,6 +36,9 @@ func registerRoutes() {
controller.Get("/dashboard", controllers.WelcomeToDashboard, hooks.AuthCheck)
// templates demos
controller.Get("/signout", controllers.Signout)
controller.Get("/appsample", controllers.AppSample, hooks.AuthCheck)
controller.Post("/appsample", controllers.AppSample, hooks.AuthCheck)