develop #6
3 changed files with 26 additions and 2 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -6,3 +6,4 @@ logs/*
|
|||
tls/*
|
||||
!tls/.gitkeep
|
||||
.DS_Store
|
||||
storage/sqlite/*
|
||||
|
|
|
@ -425,8 +425,28 @@ func SetNewPassword(c *core.Context) *core.Response {
|
|||
}
|
||||
|
||||
func Signout(c *core.Context) *core.Response {
|
||||
tokenRaw := c.GetHeader("Authorization")
|
||||
token := strings.TrimSpace(strings.Replace(tokenRaw, "Bearer", "", 1))
|
||||
|
||||
// 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))
|
||||
}
|
||||
|
||||
if token == "" {
|
||||
return c.Response.SetStatusCode(http.StatusUnauthorized).Json(c.MapToJson(map[string]interface{}{
|
||||
"message": "unauthorized",
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in a new issue