MCPcopy Create free account
hub / github.com/TruthHun/DocHub / Login

Method Login

controllers/AdminControllers/LoginController.go:30–49  ·  view source on GitHub ↗

登录后台

()

Source from the content-addressed store, hash-verified

28
29//登录后台
30func (this *LoginController) Login() {
31 this.EnableXSRF = true
32 this.Data["Sys"], _ = models.NewSys().Get()
33 if this.Ctx.Request.Method == "GET" {
34 this.Xsrf()
35 this.TplName = "index.html"
36 } else {
37 var (
38 msg string = "登录失败,用户名或密码不正确"
39 admin models.Admin
40 )
41 this.ParseForm(&admin)
42 if admin, err := models.NewAdmin().Login(admin.Username, admin.Password, admin.Code); err == nil && admin.Id > 0 {
43 this.SetSession("AdminId", admin.Id)
44 this.ResponseJson(true, "登录成功")
45 } else {
46 this.ResponseJson(false, msg)
47 }
48 }
49}
50
51//更新登录密码
52func (this *LoginController) UpdatePwd() {

Callers

nothing calls this directly

Calls 4

XsrfMethod · 0.95
ParseFormMethod · 0.80
GetMethod · 0.45
ResponseJsonMethod · 0.45

Tested by

no test coverage detected