Account.go 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. package controllers
  2. import (
  3. "bzd_server/lib"
  4. "bzd_server/models/Account"
  5. "bzd_server/models/System"
  6. beego "github.com/beego/beego/v2/server/web"
  7. "time"
  8. )
  9. type AccountController struct {
  10. beego.Controller
  11. }
  12. func (c *AccountController) Login_html() {
  13. c.TplName = "login.html"
  14. }
  15. // 验证登录
  16. func (c *AccountController) Login_verification() {
  17. Admin_user := c.GetString("bzd_username")
  18. Admin_pass := c.GetString("bzd_password")
  19. println("Login_verification", Admin_user, Admin_pass)
  20. err, user_r := Account.Read_User_verification(Admin_user, Admin_pass)
  21. if err != nil {
  22. c.Data["json"] = lib.JSONS{Code: 202, Msg: "E!"}
  23. } else {
  24. User_tokey := Account.Add_Tokey(user_r.T_uuid)
  25. c.Ctx.SetCookie("User_tokey", User_tokey, time.Second*60*60)
  26. c.Data["json"] = lib.JSONS{Code: 200, Msg: "OK!", Data: User_tokey}
  27. System.Add_UserLogs(user_r.T_uuid,"登陆", "用户登陆", "")
  28. }
  29. c.ServeJSON()
  30. return
  31. }
  32. // 验证登录
  33. func (c *AccountController) Login_Admin_verification() {
  34. Admin_user := c.GetString("bzd_username")
  35. Admin_pass := c.GetString("bzd_password")
  36. println("Login_Admin_verification", Admin_user, Admin_pass)
  37. err, user_r := Account.Read_Admin_verification(Admin_user, Admin_pass)
  38. if err != nil {
  39. c.Data["json"] = lib.JSONS{Code: 202, Msg: "E!"}
  40. } else {
  41. User_tokey := Account.Add_Tokey(user_r.T_uuid)
  42. c.Ctx.SetCookie("User_tokey", User_tokey, time.Second*60*60)
  43. c.Data["json"] = lib.JSONS{Code: 200, Msg: "OK!", Data: User_tokey}
  44. System.Add_UserLogs(user_r.T_uuid,"登陆", "管理员登陆", "")
  45. }
  46. c.ServeJSON()
  47. return
  48. }
  49. // --------------------------------------------------------------------------------------------------------------