Browse Source

短信网关请求失败,提示更友好

chenyongxing 6 years ago
parent
commit
ff46cbed54

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

@ -1,5 +1,6 @@
package com.yihu.jw.security.oauth2.provider.endpoint;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.security.core.userdetails.jdbc.WlyyUserDetailsService;
import com.yihu.jw.security.model.*;
@ -327,7 +328,17 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
            headers.set("Pragma", "no-cache");
            return new ResponseEntity<>(oauth2Envelop, headers, HttpStatus.OK);
        }
        throw new IllegalStateException((String) result.get("message"));
        String message = (String) result.get("message");
        try {
            JSONObject jsonStr = JSONObject.parseObject(message);
            if(jsonStr.containsKey("Message")){
                message = jsonStr.getString("Message");
            }
        } catch (Exception e) {
        }
        throw new IllegalStateException(message);
        /*Captcha _captcha = new Captcha();
        _captcha.setCode("12345");
        _captcha.setExpiresIn(10000);
@ -511,7 +522,7 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        } else if (e instanceof IllegalAccessException) {
            return handleOAuth2Exception(new Oauth2Envelop("短信请求频率过快,请稍后再试!", -1), e);
        } else if (e instanceof IllegalStateException) {
            return handleOAuth2Exception(new Oauth2Envelop("短信网关请求失败!", -1), e);
            return handleOAuth2Exception(new Oauth2Envelop(e.getMessage(), -1), e);
        }
        return handleOAuth2Exception(new Oauth2Envelop(e.getMessage(), -1), e);
    }