⚡ optimize the list of comments
This commit is contained in:
@@ -4,36 +4,36 @@ import "encoding/json"
|
||||
|
||||
// RefreshTokenRequest 刷新token请求
|
||||
type RefreshTokenRequest struct {
|
||||
RefreshToken string `json:"refresh_token"`
|
||||
RefreshToken string `json:"refresh_token" binding:"required"`
|
||||
}
|
||||
|
||||
// PhoneLoginRequest 手机号登录请求
|
||||
type PhoneLoginRequest struct {
|
||||
Phone string `json:"phone"`
|
||||
Captcha string `json:"captcha"`
|
||||
AutoLogin bool `json:"auto_login"`
|
||||
Phone string `json:"phone" binding:"required"`
|
||||
Captcha string `json:"captcha" binding:"required"`
|
||||
AutoLogin bool `json:"auto_login" binding:"required"`
|
||||
}
|
||||
|
||||
// AccountLoginRequest 账号登录请求
|
||||
type AccountLoginRequest struct {
|
||||
Account string `json:"account"`
|
||||
Password string `json:"password"`
|
||||
AutoLogin bool `json:"auto_login"`
|
||||
Account string `json:"account" binding:"required"`
|
||||
Password string `json:"password" binding:"required"`
|
||||
AutoLogin bool `json:"auto_login" binding:"required"`
|
||||
}
|
||||
|
||||
// AddUserRequest 新增用户请求
|
||||
type AddUserRequest struct {
|
||||
Username string `json:"username"`
|
||||
Password string `json:"password"`
|
||||
Phone string `json:"phone"`
|
||||
Username string `json:"username" binding:"required"`
|
||||
Password string `json:"password" binding:"required"`
|
||||
Phone string `json:"phone" binding:"required"`
|
||||
}
|
||||
|
||||
// ResetPasswordRequest 重置密码请求
|
||||
type ResetPasswordRequest struct {
|
||||
Phone string `json:"phone"`
|
||||
Captcha string `json:"captcha"`
|
||||
Password string `json:"password"`
|
||||
Repassword string `json:"repassword"`
|
||||
Phone string `json:"phone" binding:"required"`
|
||||
Captcha string `json:"captcha" binding:"required"`
|
||||
Password string `json:"password" binding:"required"`
|
||||
Repassword string `json:"repassword" binding:"required"`
|
||||
}
|
||||
|
||||
// ResponseData 返回数据
|
||||
|
@@ -118,10 +118,6 @@ func (UserAPI) AccountLogin(c *gin.Context) {
|
||||
}
|
||||
account := accountLoginRequest.Account
|
||||
password := accountLoginRequest.Password
|
||||
if account == "" || password == "" {
|
||||
result.FailWithMessage(ginI18n.MustGetMessage(c, "AccountAndPasswordNotEmpty"), c)
|
||||
return
|
||||
}
|
||||
|
||||
var user model.ScaAuthUser
|
||||
if utils.IsPhone(account) {
|
||||
@@ -163,10 +159,6 @@ func (UserAPI) PhoneLogin(c *gin.Context) {
|
||||
phone := request.Phone
|
||||
captcha := request.Captcha
|
||||
autoLogin := request.AutoLogin
|
||||
if phone == "" || captcha == "" {
|
||||
result.FailWithMessage(ginI18n.MustGetMessage(c, "PhoneAndCaptchaNotEmpty"), c)
|
||||
return
|
||||
}
|
||||
if !utils.IsPhone(phone) {
|
||||
result.FailWithMessage(ginI18n.MustGetMessage(c, "PhoneErrorFormat"), c)
|
||||
return
|
||||
@@ -273,10 +265,6 @@ func (UserAPI) RefreshHandler(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
refreshToken := request.RefreshToken
|
||||
if refreshToken == "" {
|
||||
result.FailWithMessage(ginI18n.MustGetMessage(c, "ParamsError"), c)
|
||||
return
|
||||
}
|
||||
parseRefreshToken, isUpd, err := utils.ParseRefreshToken(refreshToken)
|
||||
if err != nil || !isUpd {
|
||||
global.LOG.Errorln(err)
|
||||
@@ -369,12 +357,6 @@ func (UserAPI) ResetPassword(c *gin.Context) {
|
||||
captcha := resetPasswordRequest.Captcha
|
||||
password := resetPasswordRequest.Password
|
||||
repassword := resetPasswordRequest.Repassword
|
||||
|
||||
if phone == "" || captcha == "" || password == "" || repassword == "" {
|
||||
result.FailWithMessage(ginI18n.MustGetMessage(c, "ParamsError"), c)
|
||||
return
|
||||
}
|
||||
|
||||
if !utils.IsPhone(phone) {
|
||||
result.FailWithMessage(ginI18n.MustGetMessage(c, "PhoneError"), c)
|
||||
return
|
||||
|
Reference in New Issue
Block a user