Trick 5 년 전
부모
커밋
835b9474dc

+ 5 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/ResultStatus.java

@ -24,4 +24,9 @@ public class ResultStatus {
    public static final Integer ERROR_PARA = 1200;//错误参数等
    public static final Integer FAILED_RESP = 1201;//返回出错
    /**
     * 图形验证码
     */
    public static final Integer IMG_CAPTCHA = 1300;//图形验证码错误
}

+ 21 - 0
server/svr-authentication/src/main/java/com/yihu/jw/security/exception/ImgCaptchaException.java

@ -0,0 +1,21 @@
package com.yihu.jw.security.exception;
import org.springframework.security.oauth2.common.exceptions.ClientAuthenticationException;
/**
 * Created by Trick on 2019/9/25.
 */
public class ImgCaptchaException extends ClientAuthenticationException {
    public ImgCaptchaException(String msg, Throwable t) {
        super(msg, t);
    }
    public ImgCaptchaException(String msg) {
        super(msg);
    }
    public String getOAuth2ErrorCode() {
        return "img_captcha error";
    }
}

+ 4 - 1
server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/endpoint/WlyyLoginEndpoint.java

@ -12,6 +12,7 @@ import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.security.core.userdetails.jdbc.WlyyUserDetailsService;
import com.yihu.jw.security.dao.OauthKeypairDao;
import com.yihu.jw.security.exception.ImgCaptchaException;
import com.yihu.jw.security.login.service.BaseLoginLogService;
import com.yihu.jw.security.model.*;
import com.yihu.jw.security.oauth2.core.redis.WlyyRedisVerifyCodeService;
@ -147,7 +148,7 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        String text = parameters.get("text");
        if(org.apache.commons.lang3.StringUtils.isNotBlank(key)&& org.apache.commons.lang3.StringUtils.isNotBlank(text)){
            if(!verifyCaptcha(key,text)){
                throw new InvalidRequestException("img_captcha error");
                throw new ImgCaptchaException("img_captcha error");
            }
        }
@ -612,6 +613,8 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
            return handleOAuth2Exception(new Oauth2Envelop("短信请求频率过快,请稍后再试!", -1), e);
        } else if (e instanceof IllegalStateException) {
            return handleOAuth2Exception(new Oauth2Envelop(e.getMessage(), -1), e);
        }else if (e instanceof ImgCaptchaException) {
            return handleOAuth2Exception(new Oauth2Envelop(e.getMessage(), ResultStatus.IMG_CAPTCHA), e);
        }
        return handleOAuth2Exception(new Oauth2Envelop(e.getMessage(), -1), e);
    }

+ 1 - 1
server/svr-authentication/src/main/resources/bootstrap.yml

@ -1,6 +1,6 @@
spring:
  application:
    name: svr-authentication-lyx
    name: svr-authentication
  cloud:
    config:
      failFast: true