xinyb
2023-12-01 a7fe1dd769a13d4ac1fd8870100e6d56521b5e06
调整app扫PC二维码认证登录后会话加载问题
2个文件已修改
44 ■■■■ 已修改文件
src/com/yc/phoneQRLogin/action/LoginQRCodeWS.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/com/yc/phoneQRLogin/listener/LoginQRCodeListener.java 42 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/com/yc/phoneQRLogin/action/LoginQRCodeWS.java
@@ -123,7 +123,7 @@
     */
    @OnClose
    public void onClose(@PathParam("dbId") String dbId, @PathParam("qrCode") String qrCode, Session session) {
        subscribe(new WebSession(-1, qrCode, dbId));
//        subscribe(new WebSession(-1, qrCode, dbId));
    }
    /**
src/com/yc/phoneQRLogin/listener/LoginQRCodeListener.java
@@ -66,7 +66,7 @@
                        SpObserver.setDBtoInstance("_" + webSession.getDbId());
                        //删除二维码
                        webSocketqrCodeIfc.delExpireQrCode(webSession.getQrCode());
                    }finally {
                    } finally {
                        SpObserver.setDBtoInstance();
                    }
                    for (WebSession ws : sessionList) {
@@ -122,8 +122,13 @@
            if (info.getUsercode() != null && info.getUsercode().length() > 30) {// 解密为明文
                info.setUsercode(ChangePassword.getDecryptPassword(EncodeUtil.replaceUrlChar(info.getUsercode())));
            }
            SpObserver.setDBtoInstance("_" + info.getDbid());
            UserAccountEntity userAccount = userAccountService.getUserInfoByTelephone(info.getUsercode());
            UserAccountEntity userAccount = null;
            try {
                SpObserver.setDBtoInstance("_" + info.getDbid());
                userAccount = userAccountService.getUserInfoByTelephone(info.getUsercode());
            } finally {
                SpObserver.setDBtoInstance();
            }
            if (userAccount != null) {
                if (userAccount.isInActive()) {
                    for (WebSession web : sessionList) {
@@ -133,27 +138,28 @@
                    }
                    return;
                }
                //认证成功后给app端返回信息(pc端要在下面写入会话中后在返回)
                for (WebSession web : sessionList) {
                    if (web.getState() != 0) {
                        getMessage(web.getSession(), 2, "认证成功");
                    }
                }
                WebSession webPC = null;//pc页面的对象
                for (WebSession web : sessionList) {
                    if (web.getState() == 0 && web.getHttpSession() != null) {
                        webPC = web;//获取是pc页面的对象
                    }
                }
                //认证成功后给app端返回信息(pc端要在下面写入会话中后在返回)
                for (WebSession web : sessionList) {
                    if (web.getState() != 0) {
                        getMessage(web.getSession(), 2, "认证成功");
                    }
                }
                if (webPC != null) {//pc登录处理
                    // 保存会话 session信息
                    LoginAction loginAction = (LoginAction) FactoryBean.getBean("loginAction");
                    boolean bol = loginAction.processLoginUserToSession("", info.getDbid() + "", webPC.getHttpSession(),
                            userAccount);
                    if (bol) {
                        //返回信息给PC端
                        getMessage(webPC.getSession(), 2, "登录成功");
                        LoginQRCodeWS.deleteWebSession(webPC.getQrCode());//成功后删除
                    synchronized (this) {
                        // 保存会话 session信息
                        LoginAction loginAction = (LoginAction) FactoryBean.getBean("loginAction");
                        boolean bol = loginAction.processLoginUserToSession("", info.getDbid() + "", webPC.getHttpSession(), userAccount);
                        if (bol) {
                            //返回信息给PC端
                            getMessage(webPC.getSession(), 2, "登录成功");
                            LoginQRCodeWS.deleteWebSession(webPC.getQrCode());//成功后删除
                        }
                    }
                }
            } else {
@@ -167,8 +173,6 @@
            for (WebSession web : sessionList) {
                getMessage(web.getSession(), -1, (e.getCause() != null ? e.getCause().getMessage() : e.getMessage()));
            }
        } finally {
            SpObserver.setDBtoInstance();
        }
    }