Skip to content
This repository has been archived by the owner on Nov 26, 2023. It is now read-only.

Commit

Permalink
fix: repair multiple redirection problems when landing
Browse files Browse the repository at this point in the history
  • Loading branch information
PBK-B committed Sep 5, 2021
1 parent af0ff59 commit bee2504
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions controllers/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,38 @@ type AdminController struct {
func (c *AdminController) Get() {
_, _, is := isLogin(c)

flash := beego.NewFlash()
if _, ok := flash.Data["notice"]; ok {
c.TplName = "admin.tpl"
return
}

if !is {
// token 获取失败或失效,或用户被禁用将跳转登陆
c.Redirect("/login", 301)
c.Finish()
return
}

c.TplName = "admin.tpl"
}

func (c *AdminController) LoginPage() {
_, _, is := isLogin(c)
token, _, is := isLogin(c)

if is {

flash := beego.NewFlash()
flash.Notice(token)
flash.Store(&c.Controller)

c.Redirect("/admin", 301)
} else {
c.TplName = "login.tpl"
c.Finish()
return
}

c.TplName = "login.tpl"

}

func isLogin(c *AdminController) (token string, user models.Users, isLogin bool) {
Expand Down

0 comments on commit bee2504

Please sign in to comment.