refactors

This commit is contained in:
Sola
2016-03-27 16:23:48 +08:00
parent 7624dd84c6
commit 83c68f7fed
4 changed files with 7 additions and 7 deletions

View File

@@ -39,7 +39,7 @@ public class OAuth2 extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
AsyncContext acxt = req.startAsync();
AsyncContext actx = req.startAsync();
String code = req.getParameter("code");
String state = req.getParameter("state");
if (Checker.hasNull(code, state)) {
@@ -51,14 +51,14 @@ public class OAuth2 extends HttpServlet {
resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED);
return;
}
acxt.start(() -> {
actx.start(() -> {
try {
WxMpService wxMpService = WxMpServlet.instance.wxMpService;
WxMpOAuth2AccessToken token = wxMpService.oauth2getAccessToken(code);
String wechat = token.getOpenId();
WxSession session = WechatSession.create();
handler.onOAuth2(acxt, (HttpServletResponse) acxt.getResponse(), wechat, session);
acxt.complete();
handler.onOAuth2(actx, (HttpServletResponse) actx.getResponse(), wechat, session);
actx.complete();
} catch (Exception e) {
e.printStackTrace();
}

View File

@@ -13,6 +13,6 @@ import javax.servlet.http.HttpServletResponse;
*/
public interface OAuth2Handler {
void onOAuth2(AsyncContext acxt, HttpServletResponse resp, String user, WxSession session);
void onOAuth2(AsyncContext actx, HttpServletResponse resp, String user, WxSession session);
}

View File

@@ -44,7 +44,7 @@ public class ProfileHandler implements WxMpMessageHandler, OAuth2Handler {
}
@Override
public void onOAuth2(AsyncContext acxt, HttpServletResponse resp, String user, WxSession session) {
public void onOAuth2(AsyncContext actx, HttpServletResponse resp, String user, WxSession session) {
try {
User u = TableUser.getByWechat(user);
if (u == null) {

View File

@@ -57,7 +57,7 @@ public class LoginHandler implements WxMpMessageHandler, OAuth2Handler {
@Override
public void onOAuth2(AsyncContext acxt, HttpServletResponse resp, String user, WxSession session) {
public void onOAuth2(AsyncContext actx, HttpServletResponse resp, String user, WxSession session) {
try {
Operator operator = TableOperator.get(user);
if (operator == null) {