feat: 代码生成
This commit is contained in:
+17
-11
@@ -32,24 +32,30 @@ func (a *AuthApi) Login(c *gin.Context) {
|
||||
response.FailWithMsg(err.Error(), c)
|
||||
return
|
||||
}
|
||||
if l.CaptchaId != "" && l.Captcha != "" && store.Verify(l.CaptchaId, l.Captcha, true) {
|
||||
u := &system.User{Account: l.Account, Password: l.Password}
|
||||
user, err := userService.Login(u)
|
||||
if err != nil {
|
||||
global.Logger.Error("登录失败! 用户名不存在或者密码错误!", zap.Error(err))
|
||||
response.FailWithMsg("用户名不存在或者密码错误", c)
|
||||
return
|
||||
}
|
||||
a.GetToken(c, *user)
|
||||
|
||||
// 验证码校验:enable-captcha=0 时跳过
|
||||
captchaOk := global.Config.System.EnableCaptcha == 0 ||
|
||||
(l.CaptchaId != "" && l.Captcha != "" && store.Verify(l.CaptchaId, l.Captcha, true))
|
||||
|
||||
if !captchaOk {
|
||||
response.FailWithMsg("验证码错误", c)
|
||||
return
|
||||
}
|
||||
response.FailWithMsg("验证码错误", c)
|
||||
|
||||
u := &system.User{Account: l.Account, Password: l.Password}
|
||||
user, err := userService.Login(u)
|
||||
if err != nil {
|
||||
global.Logger.Error("登录失败! 用户名不存在或者密码错误!", zap.Error(err))
|
||||
response.FailWithMsg("用户名不存在或者密码错误", c)
|
||||
return
|
||||
}
|
||||
a.GetToken(c, *user)
|
||||
}
|
||||
|
||||
// Logout
|
||||
// @Tags 登录相关
|
||||
// @Summary pc登出
|
||||
// @Security ApiKeyAuth
|
||||
// @Security BasicAuth
|
||||
// @Produce application/json
|
||||
// @Success 200 {object} response.Response{msg=string} "登出成功"
|
||||
// @Router /api/auth/logout [get]
|
||||
|
||||
Reference in New Issue
Block a user