...
|
...
|
@@ -37,7 +37,10 @@ func (c *AuthController) RefreshToken() { |
|
|
return
|
|
|
}
|
|
|
err = serveauth.ResetLoginTokenRedis(logintoken)
|
|
|
msg = protocol.NewReturnResponse(logintoken, err)
|
|
|
data := protocol.ResponseLogin{
|
|
|
Access: logintoken,
|
|
|
}
|
|
|
msg = protocol.NewReturnResponse(data, err)
|
|
|
return
|
|
|
}
|
|
|
|
...
|
...
|
@@ -72,13 +75,51 @@ func (c *AuthController) Login() { |
|
|
if err != nil {
|
|
|
log.Error("token 信息记录redis失败")
|
|
|
}
|
|
|
data := map[string]interface{}{
|
|
|
"access": logintoken,
|
|
|
data := protocol.ResponseLogin{
|
|
|
Access: logintoken,
|
|
|
}
|
|
|
msg = protocol.NewReturnResponse(data, nil)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// LoginSms 登录
|
|
|
// @router /login [post]
|
|
|
func (c *AuthController) LoginSms() {
|
|
|
var msg *protocol.ResponseMessage
|
|
|
defer func() {
|
|
|
c.ResposeJson(msg)
|
|
|
}()
|
|
|
|
|
|
var param protocol.RequestLogin
|
|
|
if err := json.Unmarshal(c.Ctx.Input.RequestBody, ¶m); err != nil {
|
|
|
log.Error("json 解析失败", err)
|
|
|
msg = protocol.BadRequestParam("1")
|
|
|
return
|
|
|
}
|
|
|
// if len(param.Account) == 0 || len(param.Password) == 0 {
|
|
|
// msg = protocol.BadRequestParam("10021")
|
|
|
// return
|
|
|
// }
|
|
|
// logintoken, err := serveauth.LoginAuthByUCenter(param.Account, param.Password)
|
|
|
// if err != nil {
|
|
|
// msg = protocol.NewReturnResponse(nil, err)
|
|
|
// return
|
|
|
// }
|
|
|
// err = serveauth.ResetLoginToken(logintoken)
|
|
|
// if err != nil {
|
|
|
// log.Error("token 信息记录数据库失败")
|
|
|
// }
|
|
|
// err = serveauth.ResetLoginTokenRedis(logintoken)
|
|
|
// if err != nil {
|
|
|
// log.Error("token 信息记录redis失败")
|
|
|
// }
|
|
|
// data := map[string]interface{}{
|
|
|
// "access": logintoken,
|
|
|
// }
|
|
|
// msg = protocol.NewReturnResponse(data, nil)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
//ChangeCompany 切换公司
|
|
|
//@Router /change_company [post]
|
|
|
func (c *AuthController) ChangeCompany() {
|
...
|
...
|
@@ -103,11 +144,18 @@ func (c *AuthController) ChangeCompany() { |
|
|
msg = protocol.NewReturnResponse(nil, err)
|
|
|
return
|
|
|
}
|
|
|
err = serveauth.ResetLoginToken(logintoken)
|
|
|
if err != nil {
|
|
|
log.Error("token 信息记录数据库失败")
|
|
|
}
|
|
|
err = redisdata.SetLoginToken(logintoken, userid, param.CompanyId)
|
|
|
if err != nil {
|
|
|
log.Error("redisdata.SetLoginToken err:%s", err)
|
|
|
}
|
|
|
msg = protocol.NewReturnResponse(logintoken, err)
|
|
|
data := protocol.ResponseLogin{
|
|
|
Access: logintoken,
|
|
|
}
|
|
|
msg = protocol.NewReturnResponse(data, err)
|
|
|
return
|
|
|
}
|
|
|
|
...
|
...
|
@@ -142,13 +190,14 @@ func (c *AuthController) Me() { |
|
|
}
|
|
|
|
|
|
const (
|
|
|
captchaID = "48a6ebac4ebc6642d68c217fca33eb4d"
|
|
|
privateKey = "4f1c085290bec5afdc54df73535fc361"
|
|
|
captchaID = "33a2abf9c5df0d6bc3b89fb39280114b"
|
|
|
privateKey = "13320fd2b10199e9a2440a4fbb4d46f7"
|
|
|
)
|
|
|
|
|
|
func (c *AuthController) RegisterGeetest() {
|
|
|
geetest := geetest.NewGeetestLib(captchaID, privateKey, 2*time.Second)
|
|
|
status, responseBt := geetest.PreProcess("", "")
|
|
|
userip := c.Ctx.Input.IP()
|
|
|
status, responseBt := geetest.PreProcess("", userip)
|
|
|
c.SetSession("geetest_status", status)
|
|
|
c.Ctx.Output.Body(responseBt)
|
|
|
return
|
...
|
...
|
|