Commit 6e3fd893 by chenxianqi

update auth logout

parent 4c5fa99a
...@@ -86,7 +86,7 @@ func (c *AuthController) Logout() { ...@@ -86,7 +86,7 @@ func (c *AuthController) Logout() {
_ = o.Read(&admin, "Token") _ = o.Read(&admin, "Token")
admin.Token = "" admin.Token = ""
admin.CurrentConUser = 0 admin.CurrentConUser = 0
if _, err := o.Update(&admin, "Token", "CurrentConUser"); err != nil { if _, err := o.Update(&admin); err != nil {
logs.Error(err) logs.Error(err)
c.Data["json"] = utils.ResponseError(c.Ctx, "退出失败!", nil) c.Data["json"] = utils.ResponseError(c.Ctx, "退出失败!", nil)
c.ServeJSON() c.ServeJSON()
......
...@@ -57,6 +57,7 @@ func (c *PublicController) Register() { ...@@ -57,6 +57,7 @@ func (c *PublicController) Register() {
// user // user
var user models.User var user models.User
var admin models.Admin
if sessionRequest.Type == 0 { if sessionRequest.Type == 0 {
// platfrom id exist // platfrom id exist
...@@ -116,7 +117,7 @@ func (c *PublicController) Register() { ...@@ -116,7 +117,7 @@ func (c *PublicController) Register() {
token := c.Ctx.Input.Header("Authorization") token := c.Ctx.Input.Header("Authorization")
// admin // admin
admin := models.Admin{Token: token} admin = models.Admin{Token: token}
if err := o.Read(&admin, "Token"); err != nil { if err := o.Read(&admin, "Token"); err != nil {
c.Data["json"] = utils.ResponseError(c.Ctx, "客服不存在!", err) c.Data["json"] = utils.ResponseError(c.Ctx, "客服不存在!", err)
c.ServeJSON() c.ServeJSON()
...@@ -145,7 +146,7 @@ func (c *PublicController) Register() { ...@@ -145,7 +146,7 @@ func (c *PublicController) Register() {
if sessionRequest.Type == 0 { if sessionRequest.Type == 0 {
resData = successData{Token: &imToken, User: &user} resData = successData{Token: &imToken, User: &user}
} else { } else {
resData = successData{Token: &imToken, User: nil} resData = successData{Token: &imToken, User: &admin}
} }
c.Data["json"] = utils.ResponseSuccess(c.Ctx, "获取成功!", &resData) c.Data["json"] = utils.ResponseSuccess(c.Ctx, "获取成功!", &resData)
c.ServeJSON() c.ServeJSON()
......
...@@ -88,7 +88,8 @@ func appTask() { ...@@ -88,7 +88,8 @@ func appTask() {
logs.Info("清理登录超时用户,有", count, "个用户被强制下线") logs.Info("清理登录超时用户,有", count, "个用户被强制下线")
// 检查Admin // 检查Admin
_, _ = aqs.Filter("online__in", 1, 2).Filter("last_activity__lte", adminOffLineUnixTimer).Update(orm.Params{ _, _ = aqs.Filter("online__in", 1, 2).Filter("last_activity__lte", adminOffLineUnixTimer).Update(orm.Params{
"online": 0, "online": 0,
"current_con_user": 0,
}) })
// 2.判断用户是否超时无应答 // 2.判断用户是否超时无应答
...@@ -167,7 +168,7 @@ func appTask() { ...@@ -167,7 +168,7 @@ func appTask() {
// 任务调度(30分钟会执行一次删除客户token) // 任务调度(30分钟会执行一次删除客户token)
// deleteAdminTokenTk := toolbox.NewTask("deleteAdminToken", "0 */30 * * * *", func() error { // deleteAdminTokenTk := toolbox.NewTask("deleteAdminToken", "0 */30 * * * *", func() error {
// o := o.QueryTable(new(models.Admin)) // o := o.QueryTable(new(models.Admin))
// o.Filter("root", 0).Update(orm.Params{ // o.Update(orm.Params{
// "token": "", // "token": "",
// }) // })
// return nil // return nil
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment