|
@ -1108,6 +1108,44 @@ public class SysService {
|
1108
|
1108
|
return ret;
|
1109
|
1109
|
}
|
1110
|
1110
|
|
|
1111
|
@SetCookie(checkResultNull = true, path = "/", value = { "userid=result.getId()", "userMobilePhone=result.getMobilePhone()", "userType=result.getType()",
|
|
1112
|
"userAuth=String.valueOf(result.isAuth())", "userEmail=result.getEmail()==null?\"\":result.getEmail()",
|
|
1113
|
"userName=result.getName()==null?\"\":java.net.URLEncoder.encode(result.getName(),\"utf-8\")" })
|
|
1114
|
@Post
|
|
1115
|
@Path("/mobileLogin")
|
|
1116
|
public SessionUser mobileLogin(@JdbcConn Connection con,String state,String mobilePhone,String validateCode)throws SQLException, JfwBaseException {
|
|
1117
|
@SuppressWarnings("unchecked")
|
|
1118
|
StateCode<String, String> sc = (StateCode<String, String>) JfwAppContext.getCachedObject(state);
|
|
1119
|
if (sc == null || sc.getExpiredTime() < System.currentTimeMillis()){
|
|
1120
|
throw new JfwBaseException(-1, "验证超时");
|
|
1121
|
}
|
|
1122
|
if (!sc.getKey().equals(mobilePhone)) {
|
|
1123
|
throw new JfwBaseException(-2, "手机号与验证手机不匹配");
|
|
1124
|
}
|
|
1125
|
if (!sc.getValue().equals(validateCode)) {
|
|
1126
|
throw new JfwBaseException(-3, "验证码错误");
|
|
1127
|
}
|
|
1128
|
User user = userDao.queryByEmailOrMobilePhone(con, mobilePhone);
|
|
1129
|
if (null == user){
|
|
1130
|
throw new JfwBaseException(-4, "该用户还未注册");
|
|
1131
|
}
|
|
1132
|
try {
|
|
1133
|
SessionUser ret = new SessionUser();
|
|
1134
|
ret.setId(user.getId());
|
|
1135
|
Professor professor = this.professorDao.query(con, user.getId());
|
|
1136
|
if (null != professor) {
|
|
1137
|
ret.setName(professor.getName());
|
|
1138
|
}
|
|
1139
|
ret.setMobilePhone(user.getMobilePhone());
|
|
1140
|
ret.setType(user.getUserType());
|
|
1141
|
ret.setEmail(user.getEmail());
|
|
1142
|
ret.setAuth(true);
|
|
1143
|
return ret;
|
|
1144
|
} finally {
|
|
1145
|
JfwAppContext.removeCachedObject(state);
|
|
1146
|
}
|
|
1147
|
}
|
|
1148
|
|
1111
|
1149
|
@SetCookie(checkResultNull = true, path = "/", value = { "orgId=result.getId()", "orgType=result.getType()",
|
1112
|
1150
|
"orgAuth=String.valueOf(result.isAuth())", "orgEmail=result.getEmail()==null?\"\":result.getEmail()",
|
1113
|
1151
|
"orgName=result.getName()==null?\"\":java.net.URLEncoder.encode(result.getName(),\"utf-8\")" })
|