コード例 #1
0
ファイル: RegistAction.java プロジェクト: creatorYC/yechblog
 /**
  * 重置密码
  *
  * @return
  */
 public String resetPsw() {
   String newPsw = model.getPassword();
   model = userService.queryUserByEmail(model.getEmail());
   model.setPassword(DataUtil.md5(newPsw));
   model.setStatus(false); // 重新设置没有验证
   model.setValidateCode(DataUtil.md5("VaLiDaTeCoDe"));
   userService.updateEntity(model);
   sendMessage(); // 发送验证邮件
   return "BlogAction";
 }
コード例 #2
0
ファイル: RegistAction.java プロジェクト: creatorYC/yechblog
 /**
  * 处理邮箱验证
  *
  * @return
  */
 public String doMessageValidate() {
   model = userService.getEntity(userId);
   // 验证激活账号,修改账号状态
   if (vcode.equals(model.getValidateCode())) {
     model.setStatus(true);
     model.setValidateCode("");
     userService.setValidate(model); // 更新status为1,validate为""
     request.setAttribute("msg", "<h3>激活成功!正在为您跳转到yechblog首页</h3>");
   } else {
     request.setAttribute("msg", "<h3>已经激活过了,不要重复激活!</h3>");
     System.out.println("已经激活过了,不要重复激活!");
   }
   return "temp";
 }
コード例 #3
0
ファイル: RegistAction.java プロジェクト: creatorYC/yechblog
 /** 校验(重写 ActionSupport 父类的方法进行校验) */
 public void validateDoRegist() {
   // 1.email 非空
   String email = model.getEmail();
   if (!ValidateUtil.isValidate(email)) {
     addFieldError("email", "email 不能为空!");
   }
   if (!ValidateUtil.isValidate(model.getUsername())) {
     addFieldError("username", "username 不能为空!");
   }
   if (!ValidateUtil.isValidate(model.getPassword())) {
     addFieldError("password", "password 不能为空!");
   }
   if (!identifyCode
       .toLowerCase()
       .equals(((String) (ActionContext.getContext().getSession().get("code"))).toLowerCase())) {
     addFieldError("identifyCode", "验证码不对!");
   }
   if (hasErrors()) {
     return;
   }
   // 2.email被占用
   if (userService.isRegisted(model.getEmail())) {
     addFieldError("email", "email 已经存在!");
   }
 }
コード例 #4
0
ファイル: RegistAction.java プロジェクト: creatorYC/yechblog
 /**
  * 进行用户注册
  *
  * @return
  */
 public String doRegist() {
   // 设置初始默认信息
   model.setCareer("未填写职位");
   model.setField("未填写领域");
   model.setCountry("中国");
   model.setBirth("未填写生日");
   model.setGender(false);
   model.setCity("未填写城市");
   model.setProvince("未填写省份");
   model.setNotes("未填写备注");
   // 密码加密
   model.setPassword(DataUtil.md5(model.getPassword()));
   model.setImage("/image/personImg.jpg"); // 保存默认图片
   model.setStatus(false); // 设置没有验证
   model.setValidateCode(DataUtil.md5("VaLiDaTeCoDe")); //
   userService.saveEntity(model);
   sendMessage(); // 发送验证邮件
   return "keepOriginUrl";
 }