Exemplo n.º 1
0
 public ActionResult RetrievePsw(string account, string verify)
 {
     //检查验证码
     if (string.IsNullOrWhiteSpace(verify) || base.HttpContext.Session["CheckCode"].Equals(null) || !verify.Equals(base.HttpContext.Session["CheckCode"].ToString(), StringComparison.OrdinalIgnoreCase))
     {
         ModelState.AddModelError("error", LoginResult.WrongVerify.GetRemark());
     }
     else
     {
         TS_USER user = new TS_USER();
         //获取用户
         user = service.GetUser(account);
         //用户不存在
         if (user == null)
         {
             ModelState.AddModelError("error", "用户不存在");
         }
         //邮箱为空或者邮箱格式错误
         else if (string.IsNullOrWhiteSpace(user.C_EMAIL) || !RegExp.IsEmail(user.C_EMAIL))
         {
             ModelState.AddModelError("error", "邮箱不存在或邮箱格式错误!");
         }
         //密码重置
         else
         {
             string str     = user.C_ACCOUNT + "|" + Constant.RESET_PWD_TOKEN;
             string content = "http://" + Request.Url.Authority + Request.Url.Segments[0] + Request.Url.Segments[1] + "ResetPsw?str=" + str;
             MailHelper.SendMail(user.C_EMAIL, "确认重置密码!", null, content, "*****@*****.**", "woaiwobaba578");
             return(Content("<script>alert('请登陆邮箱确认重置密码!');window.location.href='../Auth/Login';</script>"));
         }
     }
     return(View());
 }
Exemplo n.º 2
0
 public ActionResult UserInsert(TS_USERDTO dto)
 {
     dto.Title = "用户添加";
     //验证数据模型
     if (!ModelState.IsValid)
     {
         return(View(dto));
     }
     //用户是否重复
     if (service.GetUser(dto.C_ACCOUNT) != null)
     {
         ModelState.AddModelError("error", "登录名重复");
         return(View(dto));
     }
     else
     {
         if (!string.IsNullOrWhiteSpace(dto.C_ACCOUNT))
         {
             dto.C_ACCOUNT = dto.C_ACCOUNT.Trim();
         }
         if (!string.IsNullOrWhiteSpace(dto.C_PASSWORD))
         {
             dto.C_PASSWORD = Encrypt.MD5(dto.C_PASSWORD.Trim());
         }
         dto.C_EMP_ID   = BaseUser.Id;
         dto.C_EMP_NAME = BaseUser.Name;
         dto.D_MOD_DT   = DateTime.Now;
         TS_USER user = AutoMapper.Mapper.Map <TS_USER>(dto);
         //用户类别1客户 2内部
         user.N_TYPE = 2;
         //新增用户
         service.UserInsert(user);
         //部门信息更新
         service.DeptOperation(dto);
         dto.ResultType = 1;
         return(View(dto));
     }
 }