84 lines
2.7 KiB
Go
84 lines
2.7 KiB
Go
package api
|
||
|
||
// import (
|
||
// "omc/core"
|
||
// "omc/core/manage"
|
||
// "omc/core/parse"
|
||
// "omc/handle/service"
|
||
|
||
// "github.com/aceld/zinx/ziface"
|
||
// "github.com/aceld/zinx/zlog"
|
||
// "github.com/aceld/zinx/znet"
|
||
// )
|
||
|
||
// var ReqCMCALoginSeqMsgID uint32 = 12
|
||
// var ReqCMCALoginSeqMsgType uint32 = 13
|
||
// var ReqCMCALoginSeqMsgName string = "ackCMCALoginSeq"
|
||
|
||
// // reqCMCALoginSeq CMCA认证方式登录随机码
|
||
// type ReqCMCALoginSeq struct {
|
||
// znet.BaseRouter
|
||
// }
|
||
|
||
// // reqCMCALoginAlarm;user=omc;key=base64Key;cert=cer;type=msg"
|
||
// func (s *ReqCMCALoginSeq) Handle(request ziface.IRequest) {
|
||
// // 登录消息处理
|
||
// body, err := parse.RequestBodyDecode(request, []string{"user", "key", "cert", "type"})
|
||
// if err != nil {
|
||
// zlog.Ins().ErrorF("inlaid message body %s", err.Error())
|
||
// request.GetConnection().SendMsg(ReqCMCALoginSeqMsgType, core.ResultError(ReqCMCALoginSeqMsgName, err.Error(), ""))
|
||
// return
|
||
// }
|
||
|
||
// // 获取当前请求的通道
|
||
// m := manage.GetManager(request.GetConnection().GetName())
|
||
// if m == nil {
|
||
// zlog.Ins().ErrorF("server internal error")
|
||
// request.GetConnection().SendMsg(ReqLoginAlarmMsgType, core.ResultError(ReqLoginAlarmMsgName, "server internal error", ""))
|
||
// return
|
||
// }
|
||
// uid, err := request.GetConnection().GetProperty("UID")
|
||
// if err != nil {
|
||
// zlog.Ins().ErrorF("GetProperty UID error %s", err)
|
||
// request.GetConnection().Stop()
|
||
// return
|
||
// }
|
||
|
||
// // 账户和消息类型
|
||
// username := body.Data["key"]
|
||
// tp := body.Data["type"]
|
||
|
||
// //登录信息check
|
||
// seqNo := m.GetUserByPID(uid.(string)).SeqNo
|
||
// if ok, err := service.CMCALogin(seqNo, username, body.Data["cert"]); !ok || err != nil {
|
||
// zlog.Ins().ErrorF("LoginFail %s", err)
|
||
// request.GetConnection().SendMsg(ReqLoginAlarmMsgType, core.Result(ReqLoginAlarmMsgName, map[string]string{
|
||
// "result": "autherror",
|
||
// "resDesc": err.Error(),
|
||
// }))
|
||
// // 已登录的,登录错误超过3次,断开连接
|
||
// if uid != nil || uid != "" {
|
||
// isClose, _ := m.LoginFail(uid.(string))
|
||
// if isClose {
|
||
// request.GetConnection().Stop()
|
||
// return
|
||
// }
|
||
// }
|
||
// return
|
||
// }
|
||
|
||
// // manager 用户登录更新
|
||
// err = m.LoginSuccess(uid.(string), username, tp)
|
||
// if err != nil {
|
||
// zlog.Ins().ErrorF("manager:%s", err)
|
||
// request.GetConnection().SendMsg(ReqLoginAlarmMsgType, core.Result(ReqLoginAlarmMsgName, map[string]string{
|
||
// "result": "autherror",
|
||
// "resDesc": err.Error(),
|
||
// }))
|
||
// return
|
||
// }
|
||
|
||
// zlog.Ins().InfoF("user login loginSuccess,username:%s, type:%s, channel:%s", username, tp, request.GetConnection().GetName())
|
||
// request.GetConnection().SendMsg(ReqLoginAlarmMsgType, core.ResultSuccess(ReqLoginAlarmMsgName, "", ""))
|
||
// }
|