|
版本: |
|
小版本号: |
|
|
|
数据库: |
|
服务器操作系统: |
|
应用服务器: |
|
客户端操作系统: |
|
浏览器: |
|
|
|
本帖最后由 milan 于 2017-6-14 17:55 编辑
1、打开/BIZ/SA/OPM/system/system.process.m,给loginAction加一个before事件
2、事件代码
- public static void systemProcessBeforeLoginAction() throws Exception {
- String name = (String) ContextHelper.getActionContext().getParameter("name");
- String pwd = (String) ContextHelper.getActionContext().getParameter("pwd");
- java.lang.System.out.println("*****************************");
- // 用户名
- java.lang.System.out.println(name);
- // 密码
- java.lang.System.out.println(pwd);
- // 这里要做个数据转换
- pwd = OrgUtils.saltPassword(pwd);
- // 这个就是和数据库里应该一致的密码了
- java.lang.System.out.println(pwd);
-
- Map<String, Object> params = new HashMap<String, Object>();
- params.put("name", name);
- // 用户名要同时判断sLoginName和sCode
- Table t = KSQL.select("SELECT p.* FROM SA_OPPerson p WHERE p.sLoginName = :name or p.sCode = :name ", params, "/system/data", null);
- // 如果用户名错误,t.size == 0
- if (t.size() > 0) {
- Row r = t.iterator().next();
- // 拿到数据库里的密码
- String pwdData = r.getString("sPassword");
- java.lang.System.out.println(pwdData);
-
- // 开启自定义事务,否则登录失败默认事务会回滚
- Transaction tran = new Transaction();
- try {
- tran.begin();
- try {
- // 这里可以获取jdbc connection
- java.sql.Connection conn = tran.getConnection("/system/data");
- // 或者用KSQL, 最后一个参数指定Transaction事务对象
- KSQL.executeUpdate("UPDATE ...", params, "/system/data", null, tran);
- // 后续逻辑......
-
- tran.commit();
- } catch(Exception e) {
- tran.rollback();
- throw e;
- }
- } finally {
- tran.closeConnections();
- }
- }
- }
复制代码
|
|