use of cn.cerc.jmis.core.ClientDevice in project summer-mis by cn-cerc.
the class AppLoginPage method checkLogin.
@Override
public boolean checkLogin(String userCode, String password) throws ServletException, IOException {
IForm form = this.getForm();
HttpServletRequest req = this.getRequest();
log.debug(String.format("校验用户帐号(%s)与密码", userCode));
// 进行设备首次登记
String deviceId = form.getClient().getId();
req.setAttribute("userCode", userCode);
req.setAttribute("password", password);
req.setAttribute("needVerify", "false");
// 如长度大于10表示用手机号码登入
if (userCode.length() > 10) {
String oldCode = userCode;
userCode = getAccountFromTel(form.getHandle(), oldCode);
log.debug(String.format("将手机号 %s 转化成帐号 %s", oldCode, userCode));
}
boolean result = false;
log.debug(String.format("进行用户帐号(%s)与密码认证", userCode));
// 进行用户名、密码认证
LocalService app;
if (form instanceof AbstractForm)
app = new LocalService((AbstractForm) form);
else
app = new LocalService(form.getHandle());
app.setService("SvrUserLogin.check");
String IP = getIPAddress();
if (app.exec("Account_", userCode, "Password_", password, "MachineID_", deviceId, "ClientIP_", IP, "Language_", form.getClient().getLanguage())) {
String sid = app.getDataOut().getHead().getString("SessionID_");
if (sid != null && !sid.equals("")) {
log.debug(String.format("认证成功,取得sid(%s)", sid));
((ClientDevice) this.getForm().getClient()).setSid(sid);
result = true;
}
} else {
// 登陆验证失败,进行判断,手机号为空,则回到登陆页,手机不为空,密码为空,则跳到发送验证码页面
String mobile = Utils.safeString(app.getDataOut().getHead().getString("Mobile_"));
if (mobile == null || "".equals(mobile)) {
log.debug(String.format("用户帐号(%s)与密码认证失败", userCode));
req.setAttribute("loginMsg", app.getMessage());
this.execute();
} else if (password == null || "".equals(password)) {
getResponse().sendRedirect("TFrmEasyReg?phone=" + mobile);
return false;
} else {
log.debug(String.format("用户帐号(%s)与密码认证失败", userCode));
req.setAttribute("loginMsg", app.getMessage());
this.execute();
}
}
return result;
}
Aggregations