mirror of
https://github.com/ZSCNetSupportDept/WechatTicketSystem.git
synced 2025-10-28 23:55:04 +08:00
refactors
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user