Commit 3972a94f by chenxianqi

支持双端登陆

parent 53db5968
Showing with 545 additions and 215 deletions
......@@ -173,6 +173,6 @@ GO 》》》》》 [小米开放平台][6]
[14]: http://kf.aissz.com:666/static/app/linux-0.0.1.AppImage
[15]: http://kf.aissz.com:666/static/app/app-release.apk
[16]: https://github.com/chenxianqi/kefu_workbench
[17]: http://qiniu.cmp520.com/kefu_workbench.apk
[17]: http://kf.aissz.com:666/static/app/kefu_workbench.apk
......@@ -24,12 +24,17 @@ type AdminController struct {
func (c *AdminController) GetMeInfo() {
o := orm.NewOrm()
token := c.Ctx.Input.Header("Authorization")
admin := models.Admin{Token: token}
if err := o.Read(&admin, "Token"); err != nil {
_auth := models.Auths{Token: token}
if err := o.Read(&_auth, "Token"); err != nil {
c.Data["json"] = utils.ResponseError(c.Ctx, "登录已失效!", nil)
c.ServeJSON()
return
}
admin := models.Admin{ID: _auth.UID}
if err := o.Read(&admin); err != nil {
c.Data["json"] = utils.ResponseError(c.Ctx, "查询失败,用户不存在", err)
} else {
admin.Password = "******"
admin.Token = "******"
c.Data["json"] = utils.ResponseSuccess(c.Ctx, "查询成功!", &admin)
}
c.ServeJSON()
......@@ -40,8 +45,18 @@ func (c *AdminController) Get() {
o := orm.NewOrm()
token := c.Ctx.Input.Header("Authorization")
_admin := models.Admin{Token: token}
_ = o.Read(&_admin, "Token")
_auth := models.Auths{Token: token}
if err := o.Read(&_auth, "Token"); err != nil {
c.Data["json"] = utils.ResponseError(c.Ctx, "登录已失效!", nil)
c.ServeJSON()
return
}
_admin := models.Admin{ID: _auth.UID}
if err := o.Read(&_admin); err != nil {
c.Data["json"] = utils.ResponseError(c.Ctx, "查询失败,用户不存在", err)
c.ServeJSON()
return
}
id, _ := strconv.ParseInt(c.Ctx.Input.Param(":id"), 10, 64)
......@@ -56,7 +71,6 @@ func (c *AdminController) Get() {
c.Data["json"] = utils.ResponseError(c.Ctx, "查询失败,用户不存在", err)
} else {
admin.Password = "******"
admin.Token = "******"
c.Data["json"] = utils.ResponseSuccess(c.Ctx, "查询成功!", &admin)
}
c.ServeJSON()
......@@ -67,8 +81,12 @@ func (c *AdminController) Put() {
o := orm.NewOrm()
token := c.Ctx.Input.Header("Authorization")
_admin := models.Admin{Token: token}
_ = o.Read(&_admin, "Token")
_auth := models.Auths{Token: token}
if err := o.Read(&_auth, "Token"); err != nil {
c.Data["json"] = utils.ResponseError(c.Ctx, "登录已失效!", nil)
c.ServeJSON()
return
}
// get request
admin := models.Admin{}
......@@ -81,14 +99,15 @@ func (c *AdminController) Put() {
}
// admin exist
if err := o.Read(&models.Admin{ID: admin.ID}); err != nil {
_oldAdmin := models.Admin{ID: _auth.UID}
if err := o.Read(&_oldAdmin); err != nil {
c.Data["json"] = utils.ResponseError(c.Ctx, "更新失败,用户不存在", err)
c.ServeJSON()
return
}
// is admin
if _admin.ID != admin.ID && _admin.Root != 1 {
if _auth.UID != admin.ID && _oldAdmin.Root != 1 {
c.Data["json"] = utils.ResponseError(c.Ctx, "您没有权限修改该客服资料!", nil)
c.ServeJSON()
return
......@@ -112,11 +131,9 @@ func (c *AdminController) Put() {
// update
if _, err := o.Update(&admin, "Phone", "NickName", "UpdateAt", "Avatar", "AutoReply"); err != nil {
logs.Error(err)
c.Data["json"] = utils.ResponseError(c.Ctx, "更新失败", err)
} else {
admin.Password = "******"
admin.Token = "******"
c.Data["json"] = utils.ResponseSuccess(c.Ctx, "更新成功!", &admin)
}
c.ServeJSON()
......@@ -129,8 +146,18 @@ func (c *AdminController) Post() {
// is admin ?
token := c.Ctx.Input.Header("Authorization")
_admin := models.Admin{Token: token}
_ = o.Read(&_admin, "Token")
_auth := models.Auths{Token: token}
if err := o.Read(&_auth, "Token"); err != nil {
c.Data["json"] = utils.ResponseError(c.Ctx, "登录已失效!", nil)
c.ServeJSON()
return
}
_admin := models.Admin{ID: _auth.UID}
if err := o.Read(&_admin); err != nil {
c.Data["json"] = utils.ResponseError(c.Ctx, "更新失败,用户不存在", err)
c.ServeJSON()
return
}
if _admin.Root != 1 {
c.Data["json"] = utils.ResponseError(c.Ctx, "您没有权限添加用户", nil)
c.ServeJSON()
......@@ -199,8 +226,14 @@ func (c *AdminController) Delete() {
id, _ := strconv.ParseInt(c.Ctx.Input.Param(":id"), 10, 64)
token := c.Ctx.Input.Header("Authorization")
_admin := models.Admin{Token: token}
_ = o.Read(&_admin, "Token")
_auth := models.Auths{Token: token}
if err := o.Read(&_auth, "Token"); err != nil {
c.Data["json"] = utils.ResponseError(c.Ctx, "登录已失效!", nil)
c.ServeJSON()
return
}
_admin := models.Admin{ID: _auth.UID}
_ = o.Read(&_admin)
if _admin.Root != 1 {
c.Data["json"] = utils.ResponseError(c.Ctx, "您没有权限删除客服!", nil)
c.ServeJSON()
......@@ -249,7 +282,6 @@ func (c *AdminController) List() {
// request body
var paginationData AdminPaginationData
if err := json.Unmarshal(c.Ctx.Input.RequestBody, &paginationData); err != nil {
logs.Error(err)
c.Data["json"] = utils.ResponseError(c.Ctx, "参数错误!", err)
c.ServeJSON()
return
......@@ -276,7 +308,6 @@ func (c *AdminController) List() {
}
total, _ := qs.Count()
for index := range lists {
lists[index].Token = "******"
lists[index].Password = "******"
}
paginationData.Total = total
......@@ -307,8 +338,14 @@ func (c *AdminController) UpdatePassword() {
// get token
token := c.Ctx.Input.Header("Authorization")
oldAdmin := models.Admin{Token: token}
_ = o.Read(&oldAdmin, "Token")
_auth := models.Auths{Token: token}
if err := o.Read(&_auth, "Token"); err != nil {
c.Data["json"] = utils.ResponseError(c.Ctx, "登录已失效!", nil)
c.ServeJSON()
return
}
oldAdmin := models.Admin{ID: _auth.UID}
_ = o.Read(&oldAdmin)
// validation
valid := validation.Validation{}
......@@ -376,8 +413,14 @@ func (c *AdminController) ChangeCurrentUser() {
// get admin token
token := c.Ctx.Input.Header("Authorization")
admin := models.Admin{Token: token}
_ = o.Read(&admin, "Token")
_auth := models.Auths{Token: token}
if err := o.Read(&_auth, "Token"); err != nil {
c.Data["json"] = utils.ResponseError(c.Ctx, "登录已失效!", nil)
c.ServeJSON()
return
}
admin := models.Admin{ID: _auth.UID}
_ = o.Read(&admin)
uid, _ := strconv.ParseInt(c.Ctx.Input.Param(":id"), 10, 64)
user := models.User{ID: uid}
......@@ -411,8 +454,15 @@ func (c *AdminController) Online() {
online = 0
}
admin := models.Admin{Token: token}
if err := o.Read(&admin, "Token"); err != nil {
_auth := models.Auths{Token: token}
if err := o.Read(&_auth, "Token"); err != nil {
c.Data["json"] = utils.ResponseError(c.Ctx, "登录已失效!", nil)
c.ServeJSON()
return
}
admin := models.Admin{ID: _auth.UID}
if err := o.Read(&admin); err != nil {
c.Data["json"] = utils.ResponseError(c.Ctx, "客服不存在!", err)
c.ServeJSON()
return
......
......@@ -6,9 +6,9 @@ import (
"encoding/json"
"kefu_server/models"
"kefu_server/utils"
"time"
"github.com/astaxie/beego"
"github.com/astaxie/beego/logs"
"github.com/astaxie/beego/orm"
"github.com/astaxie/beego/validation"
)
......@@ -18,26 +18,32 @@ type AuthController struct {
beego.Controller
}
// LoginRequest login
// auth_type 登录客户端标识ID
// username 用户名
// password 密码
type LoginRequest struct {
AuthType int64 `json:"auth_type"`
UserName string `json:"username"`
Password string `ojson:"password"`
}
// Login admin login
func (c *AuthController) Login() {
var admin models.Admin
var loginRequest LoginRequest
valid := validation.Validation{}
if err := json.Unmarshal(c.Ctx.Input.RequestBody, &admin); err != nil {
logs.Error(err)
if err := json.Unmarshal(c.Ctx.Input.RequestBody, &loginRequest); err != nil {
c.Data["json"] = utils.ResponseError(c.Ctx, "参数错误", nil)
c.ServeJSON()
return
}
// MD5
m5 := md5.New()
m5.Write([]byte(admin.Password))
admin.Password = hex.EncodeToString(m5.Sum(nil))
// valid
valid.Required(admin.UserName, "username").Message("用户名不能为空!")
valid.Required(admin.Password, "password").Message("密码不能为空!")
valid.Required(loginRequest.UserName, "username").Message("用户名不能为空!")
valid.Required(loginRequest.Password, "password").Message("密码不能为空!")
valid.Required(loginRequest.AuthType, "auth_type").Message("登录客户端标识auth_type不能为空!")
if valid.HasErrors() {
......@@ -50,29 +56,52 @@ func (c *AuthController) Login() {
}
// else if queryAdmin.Token != "" {
// c.Data["json"] = utils.ResponseError(c.Ctx, "该用户已登录,请稍后再试哦!", nil)
// }
// MD5
m5 := md5.New()
m5.Write([]byte(loginRequest.Password))
loginRequest.Password = hex.EncodeToString(m5.Sum(nil))
o := orm.NewOrm()
queryAdmin := models.Admin{UserName: admin.UserName}
/// auth_type exist ?
authType := models.AuthTypes{ID: loginRequest.AuthType}
if err := o.Read(&authType); err != nil {
c.Data["json"] = utils.ResponseError(c.Ctx, "客户端标识不存在!", nil)
c.ServeJSON()
return
}
queryAdmin := models.Admin{UserName: loginRequest.UserName}
err := o.Read(&queryAdmin, "UserName")
if err != nil {
c.Data["json"] = utils.ResponseError(c.Ctx, "用户不存在!", nil)
} else if queryAdmin.Password != admin.Password {
} else if queryAdmin.Password != loginRequest.Password {
c.Data["json"] = utils.ResponseError(c.Ctx, "密码错误!", nil)
} else if admin.UserName != queryAdmin.UserName {
} else if loginRequest.UserName != queryAdmin.UserName {
c.Data["json"] = utils.ResponseError(c.Ctx, "用户不存在!", nil)
} else {
queryAdmin.Token = utils.GenerateToken(queryAdmin)
_, err := o.Update(&queryAdmin, "Token")
queryAdmin.Password = ""
if err != nil {
logs.Error(err)
c.Data["json"] = utils.ResponseError(c.Ctx, "登录失败,请稍后再试!", queryAdmin)
newToken := utils.GenerateToken(models.JwtKey{ID: queryAdmin.ID, UserName: queryAdmin.UserName, AuthType: authType.ID})
auth := models.Auths{}
as := o.QueryTable(auth)
if err := as.Filter("auth_type", loginRequest.AuthType).Filter("uid", queryAdmin.ID).One(&auth); err != nil {
auth.Token = newToken
auth.UID = queryAdmin.ID
auth.AuthType = authType.ID
auth.UpdateAt = time.Now().Unix()
auth.CreateAt = time.Now().Unix()
if _, err := o.Insert(&auth); err != nil {
c.Data["json"] = utils.ResponseError(c.Ctx, "登录失败", &err)
c.ServeJSON()
return
}
} else {
c.Data["json"] = utils.ResponseSuccess(c.Ctx, "登录成功!", queryAdmin)
auth.Token = newToken
auth.UpdateAt = time.Now().Unix()
o.Update(&auth)
}
queryAdmin.Password = ""
queryAdmin.Token = newToken
c.Data["json"] = utils.ResponseSuccess(c.Ctx, "登录成功!", queryAdmin)
}
c.ServeJSON()
......@@ -82,17 +111,25 @@ func (c *AuthController) Login() {
func (c *AuthController) Logout() {
o := orm.NewOrm()
token := c.Ctx.Input.Header("Authorization")
admin := models.Admin{Token: token}
_ = o.Read(&admin, "Token")
admin.Token = ""
admin.CurrentConUser = 0
admin.Online = 0
if _, err := o.Update(&admin); err != nil {
logs.Error(err)
c.Data["json"] = utils.ResponseError(c.Ctx, "退出失败!", nil)
_auth := models.Auths{Token: token}
if err := o.Read(&_auth, "Token"); err != nil {
c.Data["json"] = utils.ResponseError(c.Ctx, "登录已失效!", nil)
c.ServeJSON()
return
}
qs := o.QueryTable(models.Auths{})
if count, _ := qs.Filter("uid", _auth.UID).Count(); count <= 1 {
admin := models.Admin{ID: _auth.UID}
_ = o.Read(&admin)
admin.CurrentConUser = 0
admin.Online = 0
if _, err := o.Update(&admin); err != nil {
c.Data["json"] = utils.ResponseError(c.Ctx, "退出失败!", nil)
c.ServeJSON()
return
}
}
o.Delete(&_auth)
c.Data["json"] = utils.ResponseSuccess(c.Ctx, "退出成功!", nil)
c.ServeJSON()
}
......@@ -21,8 +21,14 @@ func (c *ContactController) GetContacts() {
o := orm.NewOrm()
token := c.Ctx.Input.Header("Authorization")
admin := models.Admin{Token: token}
_ = o.Read(&admin, "Token")
_auth := models.Auths{Token: token}
if err := o.Read(&_auth, "Token"); err != nil {
c.Data["json"] = utils.ResponseError(c.Ctx, "登录已失效!", nil)
c.ServeJSON()
return
}
admin := models.Admin{ID: _auth.UID}
_ = o.Read(&admin)
var contactData []models.ContactData
rCount, err := o.Raw("SELECT c.id AS cid,c.to_account,c.is_session_end, c.last_message,c.last_message_type,c.from_account, c.create_at AS contact_create_at,u.*, IFNULL(m.`count`,0) AS `read` FROM `contact` c LEFT JOIN `user` u ON c.from_account = u.id LEFT JOIN (SELECT to_account,from_account, COUNT(*) as `count` FROM message WHERE `read` = 1 GROUP BY to_account,from_account) m ON m.to_account = c.to_account AND m.from_account = c.from_account WHERE c.to_account = ? AND c.delete = 0 ORDER BY c.create_at DESC", admin.ID).QueryRows(&contactData)
if err != nil {
......@@ -50,8 +56,16 @@ func (c *ContactController) Delete() {
id, _ := strconv.ParseInt(c.Ctx.Input.Param(":id"), 10, 64)
token := c.Ctx.Input.Header("Authorization")
admin := models.Admin{Token: token}
_ = o.Read(&admin, "Token")
_auth := models.Auths{Token: token}
if err := o.Read(&_auth, "Token"); err != nil {
c.Data["json"] = utils.ResponseError(c.Ctx, "登录已失效!", nil)
c.ServeJSON()
return
}
admin := models.Admin{ID: _auth.UID}
_ = o.Read(&admin)
res, _ := o.Raw("UPDATE `contact` SET `delete` = 1 WHERE id = ? AND to_account = ?", id, admin.ID).Exec()
if rowsAffected, _ := res.RowsAffected(); rowsAffected == 0 {
c.Data["json"] = utils.ResponseError(c.Ctx, "删除失败!", nil)
......@@ -68,8 +82,15 @@ func (c *ContactController) Clear() {
o := orm.NewOrm()
token := c.Ctx.Input.Header("Authorization")
admin := models.Admin{Token: token}
_ = o.Read(&admin, "Token")
_auth := models.Auths{Token: token}
if err := o.Read(&_auth, "Token"); err != nil {
c.Data["json"] = utils.ResponseError(c.Ctx, "登录已失效!", nil)
c.ServeJSON()
return
}
admin := models.Admin{ID: _auth.UID}
_ = o.Read(&admin)
res, _ := o.Raw("UPDATE `contact` SET `delete` = 1 WHERE to_account = ?", admin.ID).Exec()
if rowsAffected, _ := res.RowsAffected(); rowsAffected == 0 {
c.Data["json"] = utils.ResponseError(c.Ctx, "清空失败!", nil)
......
......@@ -30,8 +30,14 @@ func (c *HomeController) Statistical() {
o := orm.NewOrm()
token := c.Ctx.Input.Header("Authorization")
admin := models.Admin{Token: token}
if err := o.Read(&admin, "Token"); err != nil {
_auth := models.Auths{Token: token}
if err := o.Read(&_auth, "Token"); err != nil {
c.Data["json"] = utils.ResponseError(c.Ctx, "登录已失效!", nil)
c.ServeJSON()
return
}
admin := models.Admin{ID: _auth.UID}
if err := o.Read(&admin); err != nil {
c.Data["json"] = utils.ResponseError(c.Ctx, "查询失败,用户不存在", err)
c.ServeJSON()
return
......@@ -110,8 +116,14 @@ func (c *HomeController) TodayActionStatistical() {
o := orm.NewOrm()
token := c.Ctx.Input.Header("Authorization")
admin := models.Admin{Token: token}
if err := o.Read(&admin, "Token"); err != nil {
_auth := models.Auths{Token: token}
if err := o.Read(&_auth, "Token"); err != nil {
c.Data["json"] = utils.ResponseError(c.Ctx, "登录已失效!", nil)
c.ServeJSON()
return
}
admin := models.Admin{ID: _auth.UID}
if err := o.Read(&admin); err != nil {
c.Data["json"] = utils.ResponseError(c.Ctx, "查询失败,用户不存在", err)
c.ServeJSON()
return
......
......@@ -37,8 +37,14 @@ func (c *MessageController) List() {
if messagePaginationData.Service == 0 {
token := c.Ctx.Input.Header("Authorization")
admin := models.Admin{Token: token}
if err := o.Read(&admin, "Token"); err != nil {
_auth := models.Auths{Token: token}
if err := o.Read(&_auth, "Token"); err != nil {
c.Data["json"] = utils.ResponseError(c.Ctx, "登录已失效!", nil)
c.ServeJSON()
return
}
admin := models.Admin{ID: _auth.UID}
if err := o.Read(&admin); err != nil {
c.Data["json"] = utils.ResponseError(c.Ctx, "查询失败,用户不存在", err)
c.ServeJSON()
return
......@@ -107,6 +113,9 @@ func (c *MessageController) List() {
payload, _ := base64.StdEncoding.DecodeString(msg.Payload)
messages[index].Payload = string(payload)
}
if len(im.Robots) > 0 {
im.PushNewContacts(serviceID, im.Robots[0])
}
c.Data["json"] = utils.ResponseSuccess(c.Ctx, "查询成功!", &messagePaginationData)
c.ServeJSON()
}
......@@ -115,14 +124,21 @@ func (c *MessageController) List() {
type RemoveRequestData struct {
FromAccount int64 `json:"from_account"`
ToAccount int64 `json:"to_account"`
Key int64 `json:"key"`
Key int64 `json:"key"`
}
// Remove one message
func (c *MessageController) Remove() {
o := orm.NewOrm()
token := c.Ctx.Input.Header("Authorization")
admin := models.Admin{Token: token}
if err := o.Read(&admin, "Token"); err != nil {
_auth := models.Auths{Token: token}
if err := o.Read(&_auth, "Token"); err != nil {
c.Data["json"] = utils.ResponseError(c.Ctx, "登录已失效!", nil)
c.ServeJSON()
return
}
admin := models.Admin{ID: _auth.UID}
if err := o.Read(&admin); err != nil {
c.Data["json"] = utils.ResponseError(c.Ctx, "无权限操作", err)
c.ServeJSON()
return
......@@ -151,9 +167,9 @@ func (c *MessageController) Remove() {
}
_, err := o.Raw("UPDATE message SET `delete` = 1 WHERE from_account = ? AND to_account = ? AND `key` = ?", removeRequestData.FromAccount, removeRequestData.ToAccount, removeRequestData.Key).Exec()
if err != nil{
if err != nil {
c.Data["json"] = utils.ResponseError(c.Ctx, "删除失败!", &err)
}else{
} else {
c.Data["json"] = utils.ResponseSuccess(c.Ctx, "删除成功", nil)
}
c.ServeJSON()
......@@ -170,8 +186,14 @@ func (c *MessageController) Transfer() {
o := orm.NewOrm()
token := c.Ctx.Input.Header("Authorization")
admin := models.Admin{Token: token}
if err := o.Read(&admin, "Token"); err != nil {
_auth := models.Auths{Token: token}
if err := o.Read(&_auth, "Token"); err != nil {
c.Data["json"] = utils.ResponseError(c.Ctx, "登录已失效!", nil)
c.ServeJSON()
return
}
admin := models.Admin{ID: _auth.UID}
if err := o.Read(&admin); err != nil {
c.Data["json"] = utils.ResponseError(c.Ctx, "查询失败,用户不存在", err)
c.ServeJSON()
return
......@@ -242,8 +264,8 @@ func (c *MessageController) Transfer() {
im.MessageInto(message, true)
// send to user
message.ToAccount = transferRequestData.UserAccount
message.FromAccount = robotID
message.ToAccount = transferRequestData.UserAccount
message.Delete = 1
message.Payload = string(toAdminJSON)
messageJSONThree, _ := json.Marshal(message)
......
......@@ -37,8 +37,14 @@ func (c *PlatformController) Put() {
o := orm.NewOrm()
token := c.Ctx.Input.Header("Authorization")
_admin := models.Admin{Token: token}
_ = o.Read(&_admin, "Token")
_auth := models.Auths{Token: token}
if err := o.Read(&_auth, "Token"); err != nil {
c.Data["json"] = utils.ResponseError(c.Ctx, "登录已失效!", nil)
c.ServeJSON()
return
}
_admin := models.Admin{ID: _auth.UID}
_ = o.Read(&_admin)
// is admin ?
if _admin.Root != 1 {
......@@ -111,8 +117,14 @@ func (c *PlatformController) Post() {
o := orm.NewOrm()
token := c.Ctx.Input.Header("Authorization")
_admin := models.Admin{Token: token}
_ = o.Read(&_admin, "Token")
_auth := models.Auths{Token: token}
if err := o.Read(&_auth, "Token"); err != nil {
c.Data["json"] = utils.ResponseError(c.Ctx, "登录已失效!", nil)
c.ServeJSON()
return
}
_admin := models.Admin{ID: _auth.UID}
_ = o.Read(&_admin)
if _admin.Root != 1 {
c.Data["json"] = utils.ResponseError(c.Ctx, "您没有权限添加平台!", nil)
c.ServeJSON()
......@@ -173,8 +185,14 @@ func (c *PlatformController) Delete() {
o := orm.NewOrm()
id, _ := strconv.ParseInt(c.Ctx.Input.Param(":id"), 10, 64)
token := c.Ctx.Input.Header("Authorization")
_admin := models.Admin{Token: token}
_ = o.Read(&_admin, "Token")
_auth := models.Auths{Token: token}
if err := o.Read(&_auth, "Token"); err != nil {
c.Data["json"] = utils.ResponseError(c.Ctx, "登录已失效!", nil)
c.ServeJSON()
return
}
_admin := models.Admin{ID: _auth.UID}
_ = o.Read(&_admin)
if _admin.Root != 1 {
c.Data["json"] = utils.ResponseError(c.Ctx, "您没有权限删除平台!", nil)
c.ServeJSON()
......
......@@ -117,8 +117,14 @@ func (c *PublicController) Register() {
token := c.Ctx.Input.Header("Authorization")
// admin
admin = models.Admin{Token: token}
if err := o.Read(&admin, "Token"); err != nil {
_auth := models.Auths{Token: token}
if err := o.Read(&_auth, "Token"); err != nil {
c.Data["json"] = utils.ResponseError(c.Ctx, "登录已失效!", nil)
c.ServeJSON()
return
}
admin := models.Admin{ID: _auth.UID}
if err := o.Read(&admin); err != nil {
c.Data["json"] = utils.ResponseError(c.Ctx, "客服不存在!", err)
c.ServeJSON()
return
......@@ -327,8 +333,14 @@ func (c *PublicController) LastActivity() {
// token
token := c.Ctx.Input.Header("Authorization")
admin := models.Admin{Token: token}
if err := o.Read(&admin, "Token"); err != nil {
_auth := models.Auths{Token: token}
if err := o.Read(&_auth, "Token"); err != nil {
c.Data["json"] = utils.ResponseError(c.Ctx, "登录已失效!", nil)
c.ServeJSON()
return
}
admin := models.Admin{ID: _auth.UID}
if err := o.Read(&admin); err != nil {
c.Data["json"] = utils.ResponseError(c.Ctx, "用户不存在!", nil)
c.ServeJSON()
return
......@@ -450,14 +462,14 @@ func (c *PublicController) GetMessageHistoryList() {
messagePaginationData := models.MessagePaginationData{}
if err := json.Unmarshal(c.Ctx.Input.RequestBody, &messagePaginationData); err != nil {
c.Data["json"] = utils.ResponseError(c.Ctx, "参数错误!", nil)
c.Data["json"] = utils.ResponseError(c.Ctx, "参数错误1!", nil)
c.ServeJSON()
return
}
token := c.Ctx.Input.Header("token")
if token == "" {
c.Data["json"] = utils.ResponseError(c.Ctx, "参数错误!", nil)
c.Data["json"] = utils.ResponseError(c.Ctx, "参数错误2!", nil)
c.ServeJSON()
return
}
......
......@@ -22,8 +22,14 @@ func (c *QiniuController) Get() {
o := orm.NewOrm()
token := c.Ctx.Input.Header("Authorization")
_admin := models.Admin{Token: token}
_ = o.Read(&_admin, "Token")
_auth := models.Auths{Token: token}
if err := o.Read(&_auth, "Token"); err != nil {
c.Data["json"] = utils.ResponseError(c.Ctx, "登录已失效!", nil)
c.ServeJSON()
return
}
_admin := models.Admin{ID: _auth.UID}
_ = o.Read(&_admin)
if _admin.Root != 1 {
c.Data["json"] = utils.ResponseError(c.Ctx, "您没有权限获取配置!", nil)
......@@ -57,8 +63,14 @@ func (c *QiniuController) Put() {
o := orm.NewOrm()
token := c.Ctx.Input.Header("Authorization")
_admin := models.Admin{Token: token}
_ = o.Read(&_admin, "Token")
_auth := models.Auths{Token: token}
if err := o.Read(&_auth, "Token"); err != nil {
c.Data["json"] = utils.ResponseError(c.Ctx, "登录已失效!", nil)
c.ServeJSON()
return
}
_admin := models.Admin{ID: _auth.UID}
_ = o.Read(&_admin)
if _admin.Root != 1 {
c.Data["json"] = utils.ResponseError(c.Ctx, "您没有权限设置!", nil)
c.ServeJSON()
......
......@@ -45,8 +45,14 @@ func (c *RobotController) Delete() {
o := orm.NewOrm()
token := c.Ctx.Input.Header("Authorization")
_admin := models.Admin{Token: token}
_ = o.Read(&_admin, "Token")
_auth := models.Auths{Token: token}
if err := o.Read(&_auth, "Token"); err != nil {
c.Data["json"] = utils.ResponseError(c.Ctx, "登录已失效!", nil)
c.ServeJSON()
return
}
_admin := models.Admin{ID: _auth.UID}
_ = o.Read(&_admin)
if _admin.Root != 1 {
c.Data["json"] = utils.ResponseError(c.Ctx, "您没有权限删除机器人!", nil)
c.ServeJSON()
......@@ -85,8 +91,14 @@ func (c *RobotController) Post() {
o := orm.NewOrm()
token := c.Ctx.Input.Header("Authorization")
_admin := models.Admin{Token: token}
_ = o.Read(&_admin, "Token")
_auth := models.Auths{Token: token}
if err := o.Read(&_auth, "Token"); err != nil {
c.Data["json"] = utils.ResponseError(c.Ctx, "登录已失效!", nil)
c.ServeJSON()
return
}
_admin := models.Admin{ID: _auth.UID}
_ = o.Read(&_admin)
if _admin.Root != 1 {
c.Data["json"] = utils.ResponseError(c.Ctx, "您没有权限添加机器人!", nil)
c.ServeJSON()
......@@ -154,8 +166,14 @@ func (c *RobotController) Put() {
o := orm.NewOrm()
token := c.Ctx.Input.Header("Authorization")
_admin := models.Admin{Token: token}
_ = o.Read(&_admin, "Token")
_auth := models.Auths{Token: token}
if err := o.Read(&_auth, "Token"); err != nil {
c.Data["json"] = utils.ResponseError(c.Ctx, "登录已失效!", nil)
c.ServeJSON()
return
}
_admin := models.Admin{ID: _auth.UID}
_ = o.Read(&_admin)
if _admin.Root != 1 {
c.Data["json"] = utils.ResponseError(c.Ctx, "您没有权限修改机器人!", nil)
c.ServeJSON()
......
......@@ -23,8 +23,14 @@ type ShortcutController struct {
func (c *ShortcutController) Get() {
o := orm.NewOrm()
token := c.Ctx.Input.Header("Authorization")
_admin := models.Admin{Token: token}
_ = o.Read(&_admin, "Token")
_auth := models.Auths{Token: token}
if err := o.Read(&_auth, "Token"); err != nil {
c.Data["json"] = utils.ResponseError(c.Ctx, "登录已失效!", nil)
c.ServeJSON()
return
}
_admin := models.Admin{ID: _auth.UID}
_ = o.Read(&_admin)
id, _ := strconv.ParseInt(c.Ctx.Input.Param(":id"), 10, 64)
shortcut := models.Shortcut{ID: id}
......@@ -50,8 +56,14 @@ func (c *ShortcutController) Put() {
o := orm.NewOrm()
token := c.Ctx.Input.Header("Authorization")
_admin := models.Admin{Token: token}
_ = o.Read(&_admin, "Token")
_auth := models.Auths{Token: token}
if err := o.Read(&_auth, "Token"); err != nil {
c.Data["json"] = utils.ResponseError(c.Ctx, "登录已失效!", nil)
c.ServeJSON()
return
}
_admin := models.Admin{ID: _auth.UID}
_ = o.Read(&_admin)
// request body
shortcut := models.Shortcut{}
......@@ -100,8 +112,14 @@ func (c *ShortcutController) Post() {
o := orm.NewOrm()
token := c.Ctx.Input.Header("Authorization")
_admin := models.Admin{Token: token}
_ = o.Read(&_admin, "Token")
_auth := models.Auths{Token: token}
if err := o.Read(&_auth, "Token"); err != nil {
c.Data["json"] = utils.ResponseError(c.Ctx, "登录已失效!", nil)
c.ServeJSON()
return
}
_admin := models.Admin{ID: _auth.UID}
_ = o.Read(&_admin)
// request body
var shortcut models.Shortcut
......@@ -149,8 +167,14 @@ func (c *ShortcutController) Delete() {
o := orm.NewOrm()
token := c.Ctx.Input.Header("Authorization")
_admin := models.Admin{Token: token}
_ = o.Read(&_admin, "Token")
_auth := models.Auths{Token: token}
if err := o.Read(&_auth, "Token"); err != nil {
c.Data["json"] = utils.ResponseError(c.Ctx, "登录已失效!", nil)
c.ServeJSON()
return
}
_admin := models.Admin{ID: _auth.UID}
_ = o.Read(&_admin)
id, _ := strconv.ParseInt(c.Ctx.Input.Param(":id"), 10, 64)
......@@ -180,8 +204,14 @@ func (c *ShortcutController) List() {
qs := o.QueryTable(shortcut)
token := c.Ctx.Input.Header("Authorization")
_admin := models.Admin{Token: token}
_ = o.Read(&_admin, "Token")
_auth := models.Auths{Token: token}
if err := o.Read(&_auth, "Token"); err != nil {
c.Data["json"] = utils.ResponseError(c.Ctx, "登录已失效!", nil)
c.ServeJSON()
return
}
_admin := models.Admin{ID: _auth.UID}
_ = o.Read(&_admin)
// query
var lists []models.Shortcut
......
......@@ -47,8 +47,14 @@ func (c *SystemController) Put() {
o := orm.NewOrm()
token := c.Ctx.Input.Header("Authorization")
_admin := models.Admin{Token: token}
_ = o.Read(&_admin, "Token")
_auth := models.Auths{Token: token}
if err := o.Read(&_auth, "Token"); err != nil {
c.Data["json"] = utils.ResponseError(c.Ctx, "登录已失效!", nil)
c.ServeJSON()
return
}
_admin := models.Admin{ID: _auth.UID}
_ = o.Read(&_admin)
if _admin.Root != 1 {
c.Data["json"] = utils.ResponseError(c.Ctx, "您没有权限修改系统设置!", nil)
c.ServeJSON()
......
......@@ -86,8 +86,14 @@ func (c *UserController) Delete() {
// is admin ?
token := c.Ctx.Input.Header("Authorization")
_admin := models.Admin{Token: token}
_ = o.Read(&_admin, "Token")
_auth := models.Auths{Token: token}
if err := o.Read(&_auth, "Token"); err != nil {
c.Data["json"] = utils.ResponseError(c.Ctx, "登录已失效!", nil)
c.ServeJSON()
return
}
_admin := models.Admin{ID: _auth.UID}
_ = o.Read(&_admin)
if _admin.Root != 1 {
c.Data["json"] = utils.ResponseError(c.Ctx, "您没有权限删除用户!", nil)
c.ServeJSON()
......
......@@ -36,11 +36,11 @@ var FilterToken = func(ctx *context.Context) {
err401(ctx)
return
}
o := orm.NewOrm()
auth := models.Auths{Token: oldToken}
if isExistInSlice == false && oldToken != "" {
token := strings.Split(oldToken, " ")[1]
admin := models.Admin{Token: oldToken}
o := orm.NewOrm()
if err := o.Read(&admin, "Token"); err != nil {
if err := o.Read(&auth, "Token"); err != nil {
err401(ctx)
return
}
......@@ -65,6 +65,8 @@ var FilterToken = func(ctx *context.Context) {
// 该换token了
if time.Now().Unix()+60*60*2 >= exp {
if newToken, err := utils.RefreshToken(token); err == nil {
auth.Token = newToken
o.Update(&auth)
ctx.Output.Header("Authorization", newToken)
}
}
......
......@@ -88,6 +88,10 @@ func MessageP2P(message models.Message) {
if isKF {
PushNewContacts(intoMessage.ToAccount, robot)
}
admin1 := models.Admin{ID: intoMessage.FromAccount}
if err := o.Read(&admin1); err == nil {
PushNewContacts(intoMessage.FromAccount, robot)
}
return
}
......@@ -197,17 +201,14 @@ func MessageP2P(message models.Message) {
if len(admins) <= 0 {
messageContent = robotData.NoServices
} else {
bizType = "transfer"
// 平均分配客服
admin := admins[0]
callbackMessage.TransferAccount = admin.ID
adminDataJSON, _ := json.Marshal(adminData{ID: admin.ID, NickName: admin.NickName, Avatar: admin.Avatar})
messageContent = string(adminDataJSON)
// 设置为已删除消息,避免客服端显示两条消息
callbackMessage.Delete = 1
// 发送一条消息告诉客服端
var newMsgJSON []byte
var newMsgBase64 string
newMsg := models.Message{}
newMsg.BizType = "transfer"
newMsg.FromAccount = message.FromAccount
......@@ -215,19 +216,38 @@ func MessageP2P(message models.Message) {
newMsg.Timestamp = time.Now().Unix()
newMsg.TransferAccount = admin.ID
newMsg.Payload = "系统将客户分配给您"
newMsgJSON, _ := json.Marshal(newMsg)
newMsgBase64 := base64.StdEncoding.EncodeToString([]byte(newMsgJSON))
newMsgJSON, _ = json.Marshal(newMsg)
newMsgBase64 = base64.StdEncoding.EncodeToString([]byte(newMsgJSON))
// 消息入库
MessageInto(newMsg, true)
PushNewContacts(admin.ID, robot)
robot.SendMessage(strconv.FormatInt(admin.ID, 10), []byte(newMsgBase64))
newMsg.FromAccount = robotID
newMsg.ToAccount = message.FromAccount
newMsg.Payload = messageContent
newMsgJSON, _ = json.Marshal(newMsg)
newMsgBase64 = base64.StdEncoding.EncodeToString([]byte(newMsgJSON))
robot.SendMessage(strconv.FormatInt(message.FromAccount, 10), []byte(newMsgBase64))
// 帮助客服发送欢迎语
newMsg.BizType = "text"
newMsg.Payload = admin.AutoReply
newMsg.ToAccount = message.FromAccount
newMsg.FromAccount = admin.ID
newMsgJSON, _ = json.Marshal(newMsg)
newMsgBase64 = base64.StdEncoding.EncodeToString([]byte(newMsgJSON))
// 发给用户
// 消息入库
MessageInto(newMsg, true)
robot.SendMessage(strconv.FormatInt(admin.ID, 10), []byte(newMsgBase64))
robot.SendMessage(strconv.FormatInt(message.FromAccount, 10), []byte(newMsgBase64))
PushNewContacts(admin.ID, robot)
// 转接入库用于统计服务次数
servicesStatistical := models.ServicesStatistical{UserAccount: message.FromAccount, ServiceAccount: admin.ID, Platform: message.Platform, TransferAccount: robotID, CreateAt: time.Now().Unix()}
_, _ = o.Insert(&servicesStatistical)
return
}
// 不符合去查知识库
......
......@@ -20,7 +20,7 @@
],
"body": {
"mode": "raw",
"raw": "{\n\t\"username\": \"cmp_keith\",\n\t\"password\": \"sr19890204\"\n}"
"raw": "{\n\t\"auth_type\": 3,\n\t\"username\": \"cmp_keith\",\n\t\"password\": \"qwe123456\"\n}\t"
},
"url": {
"raw": "{{HOST}}/v1/auth/login",
......@@ -50,6 +50,11 @@
"name": "Content-Type",
"type": "text",
"value": "application/json"
},
{
"key": "Authorization",
"value": "{{TOKEN}}",
"type": "text"
}
],
"body": {
......@@ -302,7 +307,7 @@
}
],
"url": {
"raw": "{{HOST}}/v1/admin/online/1",
"raw": "{{HOST}}/v1/admin/online/0",
"host": [
"{{HOST}}"
],
......@@ -310,10 +315,10 @@
"v1",
"admin",
"online",
"1"
"0"
]
},
"description": "获取当前登录用户信息"
"description": "更新用户状态"
},
"response": []
},
......@@ -343,7 +348,7 @@
],
"body": {
"mode": "raw",
"raw": "{\n \"old_password\": \"q123456\",\n \"new_password\": \"123456\",\n \"enter_password\": \"123456\"\n}"
"raw": "{\n \"old_password\": \"qwe123456\",\n \"new_password\": \"chenxinqi\",\n \"enter_password\": \"chenxinqi\"\n}"
},
"url": {
"raw": "{{HOST}}/v1/admin/password",
......@@ -508,7 +513,7 @@
],
"body": {
"mode": "raw",
"raw": "{\n \"page_on\": 1,\n \"page_size\": 10\n}"
"raw": "{\n \"page_on\": 3,\n \"page_size\": 10\n}"
},
"url": {
"raw": "{{HOST}}/v1/knowledge/list",
......@@ -1017,20 +1022,23 @@
{
"key": "Authorization",
"type": "text",
"value": "{{TOKEN}}",
"disabled": true
"value": "{{TOKEN}}"
},
{
"key": "Content-Type",
"name": "Content-Type",
"type": "text",
"value": "application/json",
"disabled": true
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n\t\"type\": 0,\n\t\"uid\": 0,\n\t\"address\": \"广州\",\n\t\"platform\": 2,\n\t\"account_id\": 10186\n}\n"
"raw": "{\n\t\"type\": 1,\n\t\"uid\": 0,\n\t\"address\": \"广州\",\n\t\"platform\": 2,\n\t\"account_id\": 100\n}\n",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{HOST}}/v1/public/register",
......@@ -1281,7 +1289,7 @@
"10637"
]
},
"description": "查询多少人在线"
"description": "设置用户是否在窗口页面"
},
"response": []
},
......@@ -1308,7 +1316,7 @@
],
"body": {
"mode": "raw",
"raw": "{\n \"platform\": 0\n}"
"raw": ""
},
"url": {
"raw": "{{HOST}}/v1/public/clean_read/10652",
......@@ -1322,7 +1330,7 @@
"10652"
]
},
"description": "获取用户新消息统计"
"description": "清除未读消息"
},
"response": []
},
......@@ -1350,7 +1358,7 @@
{
"key": "file",
"type": "file",
"src": "/Users/chenxianqi/Downloads/avatar_default.png"
"src": "/Users/chenxianqi/Downloads/未标题-1.jpg"
},
{
"key": "file_name",
......@@ -1382,7 +1390,7 @@
{
"key": "token",
"type": "text",
"value": "bJRLeg7AgtSh0T13YjL/IFDdK0JTjCJG4KdSfB9L7c0N56uq0EiflNyh2H5qmlOwqeOEcudSjEicejSfy+BJz2ui/bkYYYPpT9rKkuChjVDMAXpIv1L7ItYzsCaYjygYQD/FuVQ+0xiiFJqDudzL2vHwjH/X7NJbH7JCqycZkfW1zemCFfMmd2X/MaLFoNJViuwJ2SSX9LBI38wn1xjcB5vdf/iemXgkphP/681AbulvHLRLZ66k+UlpgCdSARnyRYH9FpopjYrwJP3szMd6RU0It7bQ5/sveyu7f/+hKdXvxQOCwP/Kvr6f3GTz8HDk6Q8Mi7sUArG3HKxxpY1Q8ItJk/KjE+pORbjJ9mc5QP7jfqICozzHGsKs30rQVIHn2Rm4HLToaQs9V+58inqH+hwDyomOK4JqKNfY4ZTsWP7k/qUEf4euSwFRp56NyKHjhTG333qEitsojbGZiH3HSg=="
"value": "bJRLeg7AgtSh0T13YjL/IDlYdxk/PPVP4KKNz2PDl7d11RrRYxVB8+c/7AyjzdwfL/rvv7dN8/triQjZFWRqmFdMZ8DkPFpEsyMjItWCNn50DJve6tLvjDdGBAIbTcLOU0fwVzvHtRSM9h/xshqR7+rJ0Gk4mnICBxkVwvcnk6M3eNgHE5nsoCIhgIaMaPhoKFkB8pO+fQOzr5Nc63UMzg9C0ZUMdg9Ih0h3r+p+ylhBGo0M6VcD+PD2L3prD5exiOrLY4v8Dr3cY627TD4iRkTfasSR5JNEP9OVkShKfNOt7kdoFK7zC2L44xKN8WhX4rLVkI1HArB/nfx3NdtG0a3StrqzxDrt+vAnoW4KMvKJ/oMcTc6n5EE6n+B3wc/GdTIByK50wP35nD4dNcGnVsRCu0IwbAsIMxfWeZQRti3bGAv0PEKCeNnA1cT1w/vMopWZ/c8QiDNiO8OOXFd58Q=="
},
{
"key": "Content-Type",
......@@ -1393,7 +1401,7 @@
],
"body": {
"mode": "raw",
"raw": "{\n \"timestamp\": 1572347076,\n \"page_size\": 10,\n \"account\": 10186\n}"
"raw": "{\n \"timestamp\": 1577627004,\n \"page_size\": 10,\n \"account\": 10246\n}"
},
"url": {
"raw": "{{HOST}}/v1/public/messages",
......@@ -1768,13 +1776,14 @@
"raw": ""
},
"url": {
"raw": "{{HOST}}/v1/qiniu",
"raw": "{{HOST}}/v1/qiniu/",
"host": [
"{{HOST}}"
],
"path": [
"v1",
"qiniu"
"qiniu",
""
]
},
"description": "获取七牛配置信息"
......@@ -1835,7 +1844,7 @@
],
"body": {
"mode": "raw",
"raw": "{\n \"timestamp\": 1572920587,\n \"page_size\": 10,\n \"account\": 274993,\n \"service\": 101\n}"
"raw": "{\n \"timestamp\": 1578922086,\n \"page_size\": 20,\n \"account\": 10315,\n \"service\": 100\n}"
},
"url": {
"raw": "{{HOST}}/v1/message/list",
......@@ -1853,6 +1862,78 @@
"response": []
},
{
"name": "/v1/message/remove",
"request": {
"method": "POST",
"header": [
{
"key": "Authorization",
"type": "text",
"value": "{{TOKEN}}"
},
{
"key": "Content-Type",
"name": "Content-Type",
"type": "text",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"to_account\": 10315,\n \"from_account\": 100,\n \"key\": 1578841923887\n}"
},
"url": {
"raw": "{{HOST}}/v1/message/remove",
"host": [
"{{HOST}}"
],
"path": [
"v1",
"message",
"remove"
]
},
"description": "移除单条消息"
},
"response": []
},
{
"name": "/v1/message/transfer",
"request": {
"method": "POST",
"header": [
{
"key": "Authorization",
"type": "text",
"value": "{{TOKEN}}"
},
{
"key": "Content-Type",
"name": "Content-Type",
"type": "text",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"to_account\": 100,\n \"user_account\": 10441\n}"
},
"url": {
"raw": "{{HOST}}/v1/message/transfer",
"host": [
"{{HOST}}"
],
"path": [
"v1",
"message",
"transfer"
]
},
"description": "客服端获取聊天记录"
},
"response": []
},
{
"name": "/v1/home/statistical",
"request": {
"method": "POST",
......@@ -1871,7 +1952,7 @@
],
"body": {
"mode": "raw",
"raw": "{\n \"date_start\": \"2019-08-15\",\n \"date_end\": \"2019-08-20\"\n}"
"raw": "{\n \"date_start\": \"2019-08-20\",\n \"date_end\": \"2019-08-20\"\n}"
},
"url": {
"raw": "{{HOST}}/v1/home/statistical",
......@@ -2017,7 +2098,7 @@
],
"body": {
"mode": "raw",
"raw": "{\n \"id\": 7,\n \"title\": \"百度小程序\",\n \"alias\": \"baidu\"\n}"
"raw": "{\n \"title\": \"百度小程序\",\n \"alias\": \"baidu\"\n}"
},
"url": {
"raw": "{{HOST}}/v1/platform",
......@@ -2148,42 +2229,6 @@
"response": []
},
{
"name": "/v1/message/transfer",
"request": {
"method": "POST",
"header": [
{
"key": "Authorization",
"type": "text",
"value": "{{TOKEN}}"
},
{
"key": "Content-Type",
"name": "Content-Type",
"type": "text",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"to_account\": 100,\n \"user_account\": 10441\n}"
},
"url": {
"raw": "{{HOST}}/v1/message/transfer",
"host": [
"{{HOST}}"
],
"path": [
"v1",
"message",
"transfer"
]
},
"description": "客服端获取聊天记录"
},
"response": []
},
{
"name": "/v1/contact/clear",
"request": {
"method": "DELETE",
......
......@@ -47,6 +47,8 @@ func initDB() {
orm.RegisterModel(new(models.QiniuSetting))
orm.RegisterModel(new(models.UploadsConfig))
orm.RegisterModel(new(models.ServicesStatistical))
orm.RegisterModel(new(models.AuthTypes))
orm.RegisterModel(new(models.Auths))
// 创建表
_ = orm.RunSyncdb("default", false, true)
......@@ -75,6 +77,7 @@ func appTask() {
o := orm.NewOrm()
// 任务调度(1分钟会执行一次)
checkOnLineTk := toolbox.NewTask("checkOnLine", "0 */1 * * * *", func() error {
im.RobotInit()
userOffLineUnixTimer := time.Now().Unix() - (60 * 10) // 用户最后活动时间T出在线状态规则
adminOffLineUnixTimer := time.Now().Unix() - (60 * 30) // 最后回复消息时间清理回话规则
lastMessageUnixTimer := time.Now().Unix() - (60 * 8) // 判断用户是否超过一定时间不使用,强制其下线
......@@ -165,16 +168,6 @@ func appTask() {
return nil
})
// 任务调度(30分钟会执行一次删除客户token)
// deleteAdminTokenTk := toolbox.NewTask("deleteAdminToken", "0 */30 * * * *", func() error {
// o := o.QueryTable(new(models.Admin))
// o.Update(orm.Params{
// "token": "",
// })
// return nil
// })
// toolbox.AddTask("deleteAdminToken", deleteAdminTokenTk)
toolbox.AddTask("checkOnLine", checkOnLineTk)
}
......
package models
// AuthTypes 登录配置模
type AuthTypes struct {
ID int64 `orm:"auto;pk;column(id)" json:"id"` // ID
Title string `orm:"type(char);column(title)" json:"title"` // 标题
}
package models
// Auths 登录授权信息
type Auths struct {
ID int64 `orm:"auto;pk;column(id)" json:"id"` // 客服(管理员)ID
AuthType int64 `orm:"column(auth_type)" json:"auth_type"` // AuthType登录配置模ID
UID int64 `orm:"column(uid)" json:"uid"` // 用户ID
Token string `orm:"null;type(text);column(token)" json:"token"` // token
UpdateAt int64 `orm:"type(bigint);column(update_at)" json:"update_at"` // 更新时间
CreateAt int64 `orm:"type(bigint);column(create_at)" json:"create_at"` // 创建时间
}
package models
// JwtKey struct
type JwtKey struct {
ID int64
AuthType int64
UserName string
}
.login[data-v-27526a96]{display:-ms-flexbox;display:flex;width:100%;height:100%;background:url(../img/login_bg.8ba760be.jpg) bottom no-repeat;background-size:cover}.login .form[data-v-27526a96]{display:-ms-flexbox;display:flex;overflow:hidden;width:600px;height:300px;background-color:#fff;margin:auto;border-radius:5px}.login .form .left[data-v-27526a96]{width:350px;height:100%;padding:20px;box-sizing:border-box;background:url(../img/login_bg1.531e0c1c.jpg) bottom no-repeat;background-size:cover;font-size:18px;color:#fff;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;-ms-flex-pack:center;justify-content:center}.login .form .left .tit[data-v-27526a96]{margin-top:50px;border-bottom:1px solid #fff}.login .form .left div[data-v-27526a96]{width:300px;padding-bottom:10px;margin-bottom:10px}.login .form .left span[data-v-27526a96]{font-size:14px}.login .form .left .client[data-v-27526a96]{margin-top:80px}.login .form .left .client button[data-v-27526a96]{margin-top:10px}.login .form .right[data-v-27526a96]{padding:20px;padding-top:50px}.login .form .right .input[data-v-27526a96]{margin-bottom:20px}.login .form .right .btn-group[data-v-27526a96]{margin-top:15px}.login .form .right .lable[data-v-27526a96]{font-size:18px;color:#606266;margin-bottom:15px;display:block}
\ No newline at end of file
.mini-im-file-button[data-v-2e63f8e9]{width:50px;height:50px;border-radius:50%;position:relative;overflow:hidden;cursor:pointer}.mini-im-file-button input[data-v-2e63f8e9]{font-size:100px;position:absolute;top:0;left:0;cursor:pointer;opacity:0}.mini-im-file-button .mini-im-file-percent[data-v-2e63f8e9]{position:absolute;top:0;left:0;width:100%;height:100%;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;border-radius:50%;background-color:rgba(0,0,0,.5);color:#fff;font-size:12px}.el-tag+.el-tag[data-v-2e63f8e9]{margin-left:10px}.button-new-tag[data-v-2e63f8e9]{margin-left:10px;height:32px;line-height:30px;padding-top:0;padding-bottom:0}.input-new-tag[data-v-2e63f8e9]{width:150px;margin-left:10px;vertical-align:bottom}.mini-im-file-button[data-v-6b34f2e3]{width:50px;height:50px;border-radius:50%;position:relative;overflow:hidden;cursor:pointer}.mini-im-file-button input[data-v-6b34f2e3]{font-size:100px;position:absolute;top:0;left:0;cursor:pointer;opacity:0}.mini-im-file-button .mini-im-file-percent[data-v-6b34f2e3]{position:absolute;top:0;left:0;width:100%;height:100%;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;border-radius:50%;background-color:rgba(0,0,0,.5);color:#fff;font-size:12px}.el-tag+.el-tag[data-v-6b34f2e3]{margin-left:10px}.button-new-tag[data-v-6b34f2e3]{margin-left:10px;height:32px;line-height:30px;padding-top:0;padding-bottom:0}.input-new-tag[data-v-6b34f2e3]{width:150px;margin-left:10px;vertical-align:bottom}.mini-im-head[data-v-dea0f158]{height:30px;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;font-size:20px;-ms-flex-pack:justify;justify-content:space-between;color:#666}.mini-im-head i[data-v-dea0f158]{margin-right:5px}
\ No newline at end of file
.mini-im-file-button[data-v-2e63f8e9]{width:50px;height:50px;border-radius:50%;position:relative;overflow:hidden;cursor:pointer}.mini-im-file-button input[data-v-2e63f8e9]{font-size:100px;position:absolute;top:0;left:0;cursor:pointer;opacity:0}.mini-im-file-button .mini-im-file-percent[data-v-2e63f8e9]{position:absolute;top:0;left:0;width:100%;height:100%;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;border-radius:50%;background-color:rgba(0,0,0,.5);color:#fff;font-size:12px}.el-tag+.el-tag[data-v-2e63f8e9]{margin-left:10px}.button-new-tag[data-v-2e63f8e9]{margin-left:10px;height:32px;line-height:30px;padding-top:0;padding-bottom:0}.input-new-tag[data-v-2e63f8e9]{width:150px;margin-left:10px;vertical-align:bottom}.mini-im-file-button[data-v-b0d0c25e]{width:50px;height:50px;border-radius:50%;position:relative;overflow:hidden;cursor:pointer}.mini-im-file-button input[data-v-b0d0c25e]{font-size:100px;position:absolute;top:0;left:0;cursor:pointer;opacity:0}.mini-im-file-button .mini-im-file-percent[data-v-b0d0c25e]{position:absolute;top:0;left:0;width:100%;height:100%;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;border-radius:50%;background-color:rgba(0,0,0,.5);color:#fff;font-size:12px}.el-tag+.el-tag[data-v-b0d0c25e]{margin-left:10px}.button-new-tag[data-v-b0d0c25e]{margin-left:10px;height:32px;line-height:30px;padding-top:0;padding-bottom:0}.input-new-tag[data-v-b0d0c25e]{width:150px;margin-left:10px;vertical-align:bottom}.mini-im-head[data-v-dea0f158]{height:30px;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;font-size:20px;-ms-flex-pack:justify;justify-content:space-between;color:#666}.mini-im-head i[data-v-dea0f158]{margin-right:5px}
\ No newline at end of file
.login[data-v-11ae6484]{display:-ms-flexbox;display:flex;width:100%;height:100%;background:url(../img/login_bg.8ba760be.jpg) bottom no-repeat;background-size:cover}.login .form[data-v-11ae6484]{display:-ms-flexbox;display:flex;overflow:hidden;width:600px;height:300px;background-color:#fff;margin:auto;border-radius:5px}.login .form .left[data-v-11ae6484]{width:350px;height:100%;padding:20px;box-sizing:border-box;background:url(../img/login_bg1.531e0c1c.jpg) bottom no-repeat;background-size:cover;font-size:18px;color:#fff;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;-ms-flex-pack:center;justify-content:center}.login .form .left .tit[data-v-11ae6484]{margin-top:50px;border-bottom:1px solid #fff}.login .form .left div[data-v-11ae6484]{width:300px;padding-bottom:10px;margin-bottom:10px}.login .form .left span[data-v-11ae6484]{font-size:14px}.login .form .left .client[data-v-11ae6484]{margin-top:80px}.login .form .left .client button[data-v-11ae6484]{margin-top:10px}.login .form .right[data-v-11ae6484]{padding:20px;padding-top:50px}.login .form .right .input[data-v-11ae6484]{margin-bottom:20px}.login .form .right .btn-group[data-v-11ae6484]{margin-top:15px}.login .form .right .lable[data-v-11ae6484]{font-size:18px;color:#606266;margin-bottom:15px;display:block}
\ No newline at end of file
.mini-im-file-button[data-v-0a24570c]{width:50px;height:50px;border-radius:50%;position:relative;overflow:hidden;cursor:pointer}.mini-im-file-button input[data-v-0a24570c]{font-size:100px;position:absolute;top:0;left:0;cursor:pointer;opacity:0}.mini-im-file-button .mini-im-file-percent[data-v-0a24570c]{position:absolute;top:0;left:0;width:100%;height:100%;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;border-radius:50%;background-color:rgba(0,0,0,.5);color:#fff;font-size:12px}.mini-im-head[data-v-0aee8f9a]{height:30px;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;font-size:20px;-ms-flex-pack:justify;justify-content:space-between;color:#666}.mini-im-head i[data-v-0aee8f9a]{margin-right:5px}.el-select .el-input[data-v-0aee8f9a]{width:130px}.input-with-select .el-input-group__prepend[data-v-0aee8f9a]{background-color:#fff}
\ No newline at end of file
.mini-im-file-button[data-v-3e845274]{width:50px;height:50px;border-radius:50%;position:relative;overflow:hidden;cursor:pointer}.mini-im-file-button input[data-v-3e845274]{font-size:100px;position:absolute;top:0;left:0;cursor:pointer;opacity:0}.mini-im-file-button .mini-im-file-percent[data-v-3e845274]{position:absolute;top:0;left:0;width:100%;height:100%;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;border-radius:50%;background-color:rgba(0,0,0,.5);color:#fff;font-size:12px}.mini-im-head[data-v-0aee8f9a]{height:30px;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;font-size:20px;-ms-flex-pack:justify;justify-content:space-between;color:#666}.mini-im-head i[data-v-0aee8f9a]{margin-right:5px}.el-select .el-input[data-v-0aee8f9a]{width:130px}.input-with-select .el-input-group__prepend[data-v-0aee8f9a]{background-color:#fff}
\ No newline at end of file
.mini-im-aside{background-color:#3e444a}.mini-im-aside,.mini-im-aside .mini-im-logo{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column}.mini-im-aside .mini-im-logo{width:100%;height:100px;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center;border-bottom:1px solid #ddd}.mini-im-aside .mini-im-logo img{height:30px}.mini-im-aside .el-menu{border-right:0}.mini-im-aside .el-badge__content{border:0;top:30px}.mini-im-aside .fix-bottom{-ms-flex-positive:1;flex-grow:1;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;-ms-flex-pack:end;justify-content:flex-end;padding-bottom:30px}.mini-im-aside .fix-bottom a{cursor:pointer;padding:0 30px;text-align:center;-ms-flex-align:center;align-items:center;color:#fff;display:-ms-flexbox;display:flex;-ms-flex-line-pack:center;align-content:center}.mini-im-aside .fix-bottom a .github-log{width:50px}.mini-im-aside .fix-bottom a span{margin-top:3px;margin-left:5px}.mini-im-header[data-v-432b9ecd]{background-color:#545c64;border-bottom:1px solid #545c64}.mini-im-header .mini-im-dropdown[data-v-432b9ecd]{height:100%}.mini-im-header .mini-im-button[data-v-432b9ecd]{border:0;font-size:35px;display:block;background:0;padding-left:0}.mini-im-header .mini-im-title[data-v-432b9ecd]{color:#fff;font-size:16px;text-align:center;line-height:60px}.mini-im-header .icon[data-v-432b9ecd]{color:#fff}.mini-im-header .el-dropdown-link[data-v-432b9ecd]{cursor:pointer;display:-ms-flexbox;display:flex;height:100%;line-height:60px;-ms-flex-align:center;align-items:center;color:#fff}.mini-im-header .el-icon-arrow-down[data-v-432b9ecd]{font-size:12px}.mini-im-file-button[data-v-0d4bcba3]{width:50px;height:50px;border-radius:50%;position:relative;overflow:hidden;cursor:pointer}.mini-im-file-button input[data-v-0d4bcba3]{font-size:100px;position:absolute;top:0;left:0;cursor:pointer;opacity:0}.mini-im-file-button .mini-im-file-percent[data-v-0d4bcba3]{position:absolute;top:0;left:0;width:100%;height:100%;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;border-radius:50%;background-color:rgba(0,0,0,.5);color:#fff;font-size:12px}.mini-im-header[data-v-61095d10]{background-color:#545c64;border-bottom:1px solid #545c64}
\ No newline at end of file
.mini-im-aside{background-color:#3e444a}.mini-im-aside,.mini-im-aside .mini-im-logo{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column}.mini-im-aside .mini-im-logo{width:100%;height:100px;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center;border-bottom:1px solid #ddd}.mini-im-aside .mini-im-logo img{height:30px}.mini-im-aside .el-menu{border-right:0}.mini-im-aside .el-badge__content{border:0;top:30px}.mini-im-aside .fix-bottom{-ms-flex-positive:1;flex-grow:1;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;-ms-flex-pack:end;justify-content:flex-end;padding-bottom:30px}.mini-im-aside .fix-bottom a{cursor:pointer;padding:0 30px;text-align:center;-ms-flex-align:center;align-items:center;color:#fff;display:-ms-flexbox;display:flex;-ms-flex-line-pack:center;align-content:center}.mini-im-aside .fix-bottom a .github-log{width:50px}.mini-im-aside .fix-bottom a span{margin-top:3px;margin-left:5px}.mini-im-header[data-v-7a297760]{background-color:#545c64;border-bottom:1px solid #545c64}.mini-im-header .mini-im-dropdown[data-v-7a297760]{height:100%}.mini-im-header .mini-im-button[data-v-7a297760]{border:0;font-size:35px;display:block;background:0;padding-left:0}.mini-im-header .mini-im-title[data-v-7a297760]{color:#fff;font-size:16px;text-align:center;line-height:60px}.mini-im-header .icon[data-v-7a297760]{color:#fff}.mini-im-header .el-dropdown-link[data-v-7a297760]{cursor:pointer;display:-ms-flexbox;display:flex;height:100%;line-height:60px;-ms-flex-align:center;align-items:center;color:#fff}.mini-im-header .el-icon-arrow-down[data-v-7a297760]{font-size:12px}.mini-im-file-button[data-v-0d4bcba3]{width:50px;height:50px;border-radius:50%;position:relative;overflow:hidden;cursor:pointer}.mini-im-file-button input[data-v-0d4bcba3]{font-size:100px;position:absolute;top:0;left:0;cursor:pointer;opacity:0}.mini-im-file-button .mini-im-file-percent[data-v-0d4bcba3]{position:absolute;top:0;left:0;width:100%;height:100%;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;border-radius:50%;background-color:rgba(0,0,0,.5);color:#fff;font-size:12px}.mini-im-header[data-v-61095d10]{background-color:#545c64;border-bottom:1px solid #545c64}
\ No newline at end of file
......@@ -47,4 +47,4 @@
}
input:-ms-input-placeholder{ /* Internet Explorer 10-11 */
color:#ccc;
}</style><link href=css/chunk-0499e026.d2993177.css rel=prefetch><link href=css/chunk-08473d3a.77daa9fe.css rel=prefetch><link href=css/chunk-2e29b63f.82fa3580.css rel=prefetch><link href=css/chunk-35027968.4de0a346.css rel=prefetch><link href=css/chunk-3a5ae4b9.36eb5b7d.css rel=prefetch><link href=css/chunk-487f5713.329fd3ec.css rel=prefetch><link href=css/chunk-771e4186.92ee7235.css rel=prefetch><link href=css/chunk-99e15be2.2e3a70e9.css rel=prefetch><link href=css/chunk-b4735d10.9f747f60.css rel=prefetch><link href=css/chunk-e3edb682.0b5ced8d.css rel=prefetch><link href=js/chunk-0499e026.accfa348.js rel=prefetch><link href=js/chunk-08473d3a.eae62d86.js rel=prefetch><link href=js/chunk-2e29b63f.7ff0f22a.js rel=prefetch><link href=js/chunk-343c8d41.f0041881.js rel=prefetch><link href=js/chunk-35027968.79ffcf7b.js rel=prefetch><link href=js/chunk-3a5ae4b9.95fb80dc.js rel=prefetch><link href=js/chunk-487f5713.773eab50.js rel=prefetch><link href=js/chunk-771e4186.f1240d97.js rel=prefetch><link href=js/chunk-99e15be2.69d71101.js rel=prefetch><link href=js/chunk-b4735d10.e80c520c.js rel=prefetch><link href=js/chunk-e3edb682.604c708b.js rel=prefetch><link href=css/app.ba710877.css rel=preload as=style><link href=css/chunk-vendors.cb739fea.css rel=preload as=style><link href=js/app.89a6f443.js rel=preload as=script><link href=js/chunk-vendors.420bd1eb.js rel=preload as=script><link href=css/chunk-vendors.cb739fea.css rel=stylesheet><link href=css/app.ba710877.css rel=stylesheet></head><body><noscript><strong>We're sorry but m doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id=app></div><script src=js/chunk-vendors.420bd1eb.js></script><script src=js/app.89a6f443.js></script></body></html>
\ No newline at end of file
}</style><link href=css/chunk-08473d3a.77daa9fe.css rel=prefetch><link href=css/chunk-3a5ae4b9.36eb5b7d.css rel=prefetch><link href=css/chunk-4033950c.ccd30c89.css rel=prefetch><link href=css/chunk-4bc425fc.a028419f.css rel=prefetch><link href=css/chunk-4d213a0b.e2ea152d.css rel=prefetch><link href=css/chunk-615380b5.0b5bbfe0.css rel=prefetch><link href=css/chunk-771e4186.92ee7235.css rel=prefetch><link href=css/chunk-b4735d10.9f747f60.css rel=prefetch><link href=css/chunk-d086e898.6a96c7a1.css rel=prefetch><link href=css/chunk-e3edb682.0b5ced8d.css rel=prefetch><link href=js/chunk-08473d3a.eae62d86.js rel=prefetch><link href=js/chunk-343c8d41.f0041881.js rel=prefetch><link href=js/chunk-3a5ae4b9.95fb80dc.js rel=prefetch><link href=js/chunk-4033950c.00c35915.js rel=prefetch><link href=js/chunk-4bc425fc.0bbe4f9b.js rel=prefetch><link href=js/chunk-4d213a0b.fb158f44.js rel=prefetch><link href=js/chunk-615380b5.8e004b72.js rel=prefetch><link href=js/chunk-771e4186.f1240d97.js rel=prefetch><link href=js/chunk-b4735d10.e80c520c.js rel=prefetch><link href=js/chunk-d086e898.72fb38e4.js rel=prefetch><link href=js/chunk-e3edb682.604c708b.js rel=prefetch><link href=css/app.ba710877.css rel=preload as=style><link href=css/chunk-vendors.cb739fea.css rel=preload as=style><link href=js/app.f25cf028.js rel=preload as=script><link href=js/chunk-vendors.420bd1eb.js rel=preload as=script><link href=css/chunk-vendors.cb739fea.css rel=stylesheet><link href=css/app.ba710877.css rel=stylesheet></head><body><noscript><strong>We're sorry but m doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id=app></div><script src=js/chunk-vendors.420bd1eb.js></script><script src=js/app.f25cf028.js></script></body></html>
\ No newline at end of file
This diff could not be displayed because it is too large.
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-35027968"],{"4f37":function(t,e,s){"use strict";s("aa77")("trim",(function(t){return function(){return t(this,3)}}))},aa77:function(t,e,s){var n=s("5ca1"),a=s("be13"),o=s("79e5"),i=s("fdef"),r="["+i+"]",c="​…",l=RegExp("^"+r+r+"*"),u=RegExp(r+r+"*$"),m=function(t,e,s){var a={},r=o((function(){return!!i[t]()||c[t]()!=c})),l=a[t]=r?e(f):i[t];s&&(a[s]=l),n(n.P+n.F*r,"String",a)},f=m.trim=function(t,e){return t=String(a(t)),1&e&&(t=t.replace(l,"")),2&e&&(t=t.replace(u,"")),t};t.exports=m},bd01:function(t,e,s){"use strict";s.r(e);var n=function(){var t=this,e=t.$createElement,s=t._self._c||e;return s("div",{staticClass:"login"},[s("div",{staticClass:"form"},[s("div",{staticClass:"left"},[s("div",{staticClass:"tit"},[t._v("欢迎回来, 请登录!")]),s("span",[t._v("客服系统-工作台")]),s("div",{staticClass:"client"},[s("p",[t._v("客户端下载")]),s("el-button",{attrs:{type:"primary",size:"mini",icon:"el-icon-download"},on:{click:t.dmac}},[t._v("Mac 版下载")]),s("el-button",{attrs:{type:"primary",size:"mini",icon:"el-icon-download"},on:{click:t.dwin}},[t._v("Windows 版下载")])],1)]),s("div",{staticClass:"right"},[s("el-form",{ref:"form",attrs:{model:t.form,onsubmit:"return false","label-width":"80px"}},[s("span",{staticClass:"lable"},[t._v("用户登录")]),s("el-input",{staticClass:"input",attrs:{placeholder:"请输入用户名","prefix-icon":"el-icon-user"},model:{value:t.form.username,callback:function(e){t.$set(t.form,"username",e)},expression:"form.username"}}),s("el-input",{staticClass:"input",attrs:{type:"password",placeholder:"请输入密码","prefix-icon":"el-icon-unlock","show-password":""},model:{value:t.form.password,callback:function(e){t.$set(t.form,"password",e)},expression:"form.password"}}),s("el-row",{staticClass:"btn-group",attrs:{type:"flex"}},[s("el-button",{attrs:{"native-type":"submit",size:"small",type:"primary"},on:{click:t.login}},[t._v("登录")]),s("el-button",{attrs:{size:"small",type:"info"}},[t._v("重置")])],1)],1)],1)])])},a=[],o=(s("4f37"),s("bc3a")),i=s.n(o),r={name:"login",data:function(){return{form:{username:"",password:""}}},mounted:function(){document.title="用户登录"},methods:{login:function(){var t=this;""!=this.form.username.trim()?""!=this.form.password.trim()?i.a.post("/auth/login",this.form).then((function(e){t.$store.commit("onChangeAdminInfo",e.data.data),t.$store.commit("onIsLogin",!0),localStorage.setItem("Authorization",e.data.data.token),t.$message({message:"登录成功!",type:"success"}),t.$router.push({path:"/index"})})).catch((function(e){console.log(e),t.$message.error(e.response.data.message)})):this.$message.error("密码不能为空!"):this.$message.error("用户名不能为空!")},dmac:function(){window.open("http://kf.aissz.com:666/static/app/mac-0.0.1.dmg")},dwin:function(){window.open("http://kf.aissz.com:666/static/app/win-0.0.1.exe")}}},c=r,l=(s("de49"),s("2877")),u=Object(l["a"])(c,n,a,!1,null,"27526a96",null);e["default"]=u.exports},de49:function(t,e,s){"use strict";var n=s("ed1b"),a=s.n(n);a.a},ed1b:function(t,e,s){},fdef:function(t,e){t.exports="\t\n\v\f\r   ᠎              \u2028\u2029\ufeff"}}]);
//# sourceMappingURL=chunk-35027968.79ffcf7b.js.map
\ No newline at end of file
This diff could not be displayed because it is too large.
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-4d213a0b"],{"4f37":function(t,e,s){"use strict";s("aa77")("trim",(function(t){return function(){return t(this,3)}}))},a84c:function(t,e,s){"use strict";var n=s("ed2b"),a=s.n(n);a.a},aa77:function(t,e,s){var n=s("5ca1"),a=s("be13"),o=s("79e5"),i=s("fdef"),r="["+i+"]",c="​…",l=RegExp("^"+r+r+"*"),u=RegExp(r+r+"*$"),m=function(t,e,s){var a={},r=o((function(){return!!i[t]()||c[t]()!=c})),l=a[t]=r?e(p):i[t];s&&(a[s]=l),n(n.P+n.F*r,"String",a)},p=m.trim=function(t,e){return t=String(a(t)),1&e&&(t=t.replace(l,"")),2&e&&(t=t.replace(u,"")),t};t.exports=m},bd01:function(t,e,s){"use strict";s.r(e);var n=function(){var t=this,e=t.$createElement,s=t._self._c||e;return s("div",{staticClass:"login"},[s("div",{staticClass:"form"},[s("div",{staticClass:"left"},[s("div",{staticClass:"tit"},[t._v("欢迎回来, 请登录!")]),s("span",[t._v("客服系统-工作台")]),s("div",{staticClass:"client"},[s("p",[t._v("客户端下载")]),s("el-button",{attrs:{type:"primary",size:"mini",icon:"el-icon-download"},on:{click:t.dmac}},[t._v("Mac 版下载")]),s("el-button",{attrs:{type:"primary",size:"mini",icon:"el-icon-download"},on:{click:t.dwin}},[t._v("Windows 版下载")])],1)]),s("div",{staticClass:"right"},[s("el-form",{ref:"form",attrs:{model:t.form,onsubmit:"return false","label-width":"80px"}},[s("span",{staticClass:"lable"},[t._v("用户登录")]),s("el-input",{staticClass:"input",attrs:{placeholder:"请输入用户名","prefix-icon":"el-icon-user"},model:{value:t.form.username,callback:function(e){t.$set(t.form,"username",e)},expression:"form.username"}}),s("el-input",{staticClass:"input",attrs:{type:"password",placeholder:"请输入密码","prefix-icon":"el-icon-unlock","show-password":""},model:{value:t.form.password,callback:function(e){t.$set(t.form,"password",e)},expression:"form.password"}}),s("el-row",{staticClass:"btn-group",attrs:{type:"flex"}},[s("el-button",{attrs:{"native-type":"submit",size:"small",type:"primary"},on:{click:t.login}},[t._v("登录")]),s("el-button",{attrs:{size:"small",type:"info"}},[t._v("重置")])],1)],1)],1)])])},a=[],o=(s("4f37"),s("bc3a")),i=s.n(o),r={name:"login",data:function(){return{form:{auth_type:1,username:"",password:""}}},mounted:function(){document.title="用户登录"},methods:{login:function(){var t=this;""!=this.form.username.trim()?""!=this.form.password.trim()?i.a.post("/auth/login",this.form).then((function(e){t.$store.commit("onChangeAdminInfo",e.data.data),t.$store.commit("onIsLogin",!0),localStorage.setItem("Authorization",e.data.data.token),t.$message({message:"登录成功!",type:"success"}),t.$router.push({path:"/index"})})).catch((function(e){console.log(e),t.$message.error(e.response.data.message)})):this.$message.error("密码不能为空!"):this.$message.error("用户名不能为空!")},dmac:function(){window.open("http://kf.aissz.com:666/static/app/mac-0.0.1.dmg")},dwin:function(){window.open("http://kf.aissz.com:666/static/app/win-0.0.1.exe")}}},c=r,l=(s("a84c"),s("2877")),u=Object(l["a"])(c,n,a,!1,null,"11ae6484",null);e["default"]=u.exports},ed2b:function(t,e,s){},fdef:function(t,e){t.exports="\t\n\v\f\r   ᠎              \u2028\u2029\ufeff"}}]);
//# sourceMappingURL=chunk-4d213a0b.fb158f44.js.map
\ No newline at end of file
......@@ -37,4 +37,4 @@
top:0 !important;
min-height: inherit!important;
left:0 !important; right:0 !important; bottom:0 !important; margin: auto !important;
}</style><link href=css/app.7e49cb6c.css rel=preload as=style><link href=css/chunk-vendors.946d2c9d.css rel=preload as=style><link href=js/app.9de5a83c.js rel=preload as=script><link href=js/chunk-vendors.5505216b.js rel=preload as=script><link href=css/chunk-vendors.946d2c9d.css rel=stylesheet><link href=css/app.7e49cb6c.css rel=stylesheet></head><body><noscript><strong>We're sorry but m doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id=app></div><script src=js/chunk-vendors.5505216b.js></script><script src=js/app.9de5a83c.js></script></body></html>
\ No newline at end of file
}</style><link href=css/app.e8544756.css rel=preload as=style><link href=css/chunk-vendors.946d2c9d.css rel=preload as=style><link href=js/app.88e6ed25.js rel=preload as=script><link href=js/chunk-vendors.1b37558e.js rel=preload as=script><link href=css/chunk-vendors.946d2c9d.css rel=stylesheet><link href=css/app.e8544756.css rel=stylesheet></head><body><noscript><strong>We're sorry but m doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id=app></div><script src=js/chunk-vendors.1b37558e.js></script><script src=js/app.88e6ed25.js></script></body></html>
\ No newline at end of file
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
......@@ -20,7 +20,7 @@ const (
// HEADER PAYLOAD SIGNATURE
// This struct is the PAYLOAD
type MyCustomClaims struct {
models.Admin
models.JwtKey
jwt.StandardClaims
}
......@@ -39,16 +39,17 @@ func RefreshToken(tokenString string) (string, error) {
mySigningKey := []byte(KEY)
expireAt := time.Now().Add(time.Second * time.Duration(DEFAULT_EXPIRE_SECONDS)).Unix()
newClaims := MyCustomClaims{
claims.Admin,
claims.JwtKey,
jwt.StandardClaims{
ExpiresAt: expireAt,
Issuer: claims.Admin.UserName,
Issuer: claims.JwtKey.UserName,
IssuedAt: time.Now().Unix(),
},
}
// generate new token with new claims
newToken := jwt.NewWithClaims(jwt.SigningMethodHS256, newClaims)
tokenStr, err := newToken.SignedString(mySigningKey)
logs.Info(tokenStr)
if err != nil {
logs.Error("generate new fresh json web token failed !! error :", err)
return "", err
......@@ -88,7 +89,7 @@ func DecodeToken(token string) (map[string]interface{}, error) {
}
// GenerateToken 生成token
func GenerateToken(admin models.Admin) (tokenString string) {
func GenerateToken(jwtKey models.JwtKey) (tokenString string) {
var expiredSeconds int
expiredSeconds = 259200
if expiredSeconds == 0 {
......@@ -97,13 +98,12 @@ func GenerateToken(admin models.Admin) (tokenString string) {
// Create the Claims
mySigningKey := []byte(KEY)
expireAt := time.Now().Add(time.Second * time.Duration(expiredSeconds)).Unix()
fmt.Println("token will be expired at ", time.Unix(expireAt, 0))
// pass parameter to this func or not
claims := MyCustomClaims{
admin,
jwtKey,
jwt.StandardClaims{
ExpiresAt: expireAt,
Issuer: admin.UserName,
Issuer: jwtKey.UserName,
IssuedAt: time.Now().Unix(),
},
}
......
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