/** @Description: 学生登陆 @Created Time: 2013-5-9 下午4:08:03 @Author lys */ public void studentLogin() { try { ServiceResult result = new ServiceResult(false); String captchaID = request.getSession().getId(); String challengeResponse = StringUtils.upperCase(request.getParameter(JCaptchaEngine.CAPTCHA_INPUT_NAME)); if (StringUtils.isEmpty(challengeResponse) || captchaService.validateResponseForID(captchaID, challengeResponse) == false) { result.setMessage("验证码错误"); ajaxJson(result.toJSON()); return; } // 根据用户名和密码判断是否允许登录 Student loginStudent = studentService.login(userCode, MD5Util.getMD5(userPwd)); if (null == loginStudent) { result.setMessage("用户名或密码错误或未注册激活!!"); } else { setSession(Student.LOGIN_ID, loginStudent.getStudentId()); setSession(Student.LOGIN_NAME, loginStudent.getStudentName()); setSession(LoginType.LOGINTYPE, LoginType.STUDENT); result.addData("studentId", loginStudent.getStudentId()); result.addData("studentName", loginStudent.getStudentName()); result.setIsSuccess(true); } String ajaxString = result.toJSON(); ajaxJson(ajaxString); } catch (Exception e) { e.printStackTrace(); } }
/** @Description: 用户端登录 @Created Time: 2013-3-29 上午11:29:36 @Author lys */ public void teacherLogin() { try { ServiceResult result = new ServiceResult(false); String captchaID = request.getSession().getId(); String challengeResponse = StringUtils.upperCase(request.getParameter(JCaptchaEngine.CAPTCHA_INPUT_NAME)); if (StringUtils.isEmpty(challengeResponse) || captchaService.validateResponseForID(captchaID, challengeResponse) == false) { result.setMessage("验证码错误"); ajaxJson(result.toJSON()); return; } // 根据用户名和密码判断是否允许登录 Teacher loginTeacher = teacherService.login(userCode, MD5Util.getMD5(userPwd)); if (null == loginTeacher) { result.setMessage("用户名或密码错误!!"); } else { setSession(Teacher.LOGIN_TEACHERID, loginTeacher.getTeacherId()); setSession(Teacher.LOGIN_TEACHERName, loginTeacher.getTeacherName()); setSession(LoginType.LOGINTYPE, LoginType.TEACHER); result.setIsSuccess(true); } String ajaxString = result.toJSON(); ajaxJson(ajaxString); } catch (Exception e) { e.printStackTrace(); } }