public ActionResult UpdatePassword(SingIn singIn) { try { int forgetPassworduserId = Convert.ToInt32(TempData["forgetPassworduserId"]); var updateUserPassword = securityAreaBs.userBs.UpdateUserPassword(singIn.resetPassword.Password, singIn.resetPassword.ConfirmPassword, forgetPassworduserId); if (updateUserPassword == true) { TempData["Msg"] = "Password reset successfully. Please go to login page to login with new password"; return(RedirectToAction("SuccessfullyResetPassword", "Login", new { area = "Security" })); } else { TempData["Fail"] = "Password reset unsuccessfully. Please contact to administrator"; return(RedirectToAction("RessetPassword", "Login", new { area = "Security" })); } } catch (Exception ex) { TempData["Fail"] = "Password reset unsuccessfully. Please contact to administrator. " + ex; return(RedirectToAction("RessetPassword", "Login", new { area = "Security" })); throw; } }
public ActionResult ForgetPassword(SingIn singIn) { try { bool IsSendSccess = false; var resFindUsersByEmail = securityAreaBs.userBs.FindUsersByEmail(singIn.forgetPassword.Email); if (resFindUsersByEmail != null) { if (resFindUsersByEmail.IsBlockByAdmin == false) { IsSendSccess = SendResetPasswordLink(resFindUsersByEmail.UserId, resFindUsersByEmail.Name, resFindUsersByEmail.Email); TempData["Msg"] = "Password reset link send to your registerd email id ."; } else { TempData["Fail"] = "Your account is banned. Please contact to administrator."; } } else { TempData["Fail"] = "Email id does not match. Please enter valid email id."; } } catch (Exception ex) { TempData["Fail"] = "Forget password link send failed" + ex; throw; } return(RedirectToAction("ForgetPassword", "Login", new { area = "Security" })); }
public ActionResult ChangePassword(SingIn singIn) { try { if (ModelState.IsValid) { int userId = Convert.ToInt32(Session[SessionObjects.CNUserId]); bool checkPassword = userBs.ChangePassword(singIn.changePassword.CurrentPassword, singIn.changePassword.Password, singIn.changePassword.ConfirmPassword, userId); TempData["Msg"] = "Password changed successfully"; return(RedirectToAction("Logout", "Login", new { area = "Security" })); } else { TempData["Fail"] = "Please check current password"; return(RedirectToAction("ChangePassword", "Dashboard", new { area = "UsersSection" })); } } catch (Exception ex) { TempData["Fail"] = "Something went worng.Please contact to administrator. " + ex; return(RedirectToAction("ChangePassword", "Dashboard", new { area = "UsersSection" })); throw; } }
public IActionResult SingIn([FromBody] SingIn paras) { //是否启用验证码 if (_redisCommon.GetValue("OnLoginVerify") == "1") { var cache = HttpContext.Session.GetString("verify"); if (string.IsNullOrEmpty(cache)) { throw ExceptionEnum.Parameter.ToEx("验证码失效"); } if (!(paras.Verify ?? "").ToLower().Equals(cache.ToLower())) { throw ExceptionEnum.Parameter.ToEx("验证码错误"); } HttpContext.Session.Clear(); } //验证账户 var model = _dbContext.SystemUser.FirstOrDefault(m => m.Code == paras.Code); if (model == null) { throw ExceptionEnum.Operating.ToEx("用户不存在"); } var mix = (paras.Code + paras.Password).ToMd5(); if (model.Password != mix) { throw ExceptionEnum.Operating.ToEx("密码错误"); } if (model.Status != 1) { throw ExceptionEnum.Disable.ToEx("账户被禁用或已删除"); } //登录记录 _dbContext.LoginRecord.Add(new LoginRecord() { Address = Request.HttpContext.Connection.LocalIpAddress.MapToIPv4().ToString(), LoginTime = DateTime.Now, UserId = model.Id, LoginType = 1 }); _dbContext.SaveChanges(); var result = new { Token = GetToken(model), Id = model.Id, Name = model.Name, Code = model.Code, Image = model.Image, Level = model.Level, Status = model.Status, Roles = model.Roles, }; return(Json(result.ToSuccess())); }
public ActionResult DeleteConfirmed(int id) { SingIn singIn = db.SingIns.Find(id); db.SingIns.Remove(singIn); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "ID,Password,UserName,LastName,Email,Birthday,Gender,Mobile,Name")] SingIn singIn) { if (ModelState.IsValid) { db.Entry(singIn).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(singIn)); }
public ActionResult Create([Bind(Include = "ID,Password,UserName,LastName,Email,Birthday,Gender,Mobile,Name")] SingIn singIn) { if (ModelState.IsValid) { db.SingIns.Add(singIn); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(singIn)); }
public void singInTestRegistroUserExist() { //Arrange var RegUser = new SingIn();//{ User = "******", Email = "*****@*****.**" }; RegUser.User = "******"; RegUser.Email = "*****@*****.**"; //Act var resultado = RegUser.singIn(); //Assert Assert.IsFalse(resultado); }
// GET: SingIns/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } SingIn singIn = db.SingIns.Find(id); if (singIn == null) { return(HttpNotFound()); } return(View(singIn)); }
public ActionResult Login(SingIn singIn) { try { if (ModelState.IsValid) { var AdminMembershipProvider = Membership.Providers["AdminMembershipProvider"]; if (AdminMembershipProvider.ValidateUser(singIn.login.Email, singIn.login.Password)) { var resAdminLogin = securityAreaBs.adminBs.GetAdminByEmail(singIn.login.Email); if (resAdminLogin.Image != null && resAdminLogin.ImageName != null && resAdminLogin.ImageType != null) { CommanDetails commanDetails = new CommanDetails(); commanDetails.Image = resAdminLogin.Image; commanDetails.ImageName = resAdminLogin.ImageName; commanDetails.ImageType = resAdminLogin.ImageType; Session["CNAdminImage"] = commanDetails; } else { Session["CNAdminImage"] = null; } Session[SessionObjects.CNAdminId] = resAdminLogin.AdminId; Session[SessionObjects.CNAdminName] = resAdminLogin.Name; Session[SessionObjects.CNAdminEmail] = resAdminLogin.Email; Session[SessionObjects.CNUserType] = Constant.USERTYPE.ADMIN; FormsAuthentication.SetAuthCookie(singIn.login.Email, false); return(RedirectToAction("Dashboard", "Dashboard", new { area = "AdminSection" })); } else { TempData["Msg"] = "Please check user name or password."; return(RedirectToAction("Login", "AdminLogin", new { area = "Security" })); } } else { TempData["Msg"] = "Please enter user name or password."; return(RedirectToAction("Login", "AdminLogin", new { area = "Security" })); } } catch (Exception ex) { TempData["Msg"] = "Login failed " + ex; return(RedirectToAction("Login", "AdminLogin", new { area = "Security" })); } }
public void singInTestRegistroUserNoExist() { //Arrange var RegUser = new SingIn();//{ User = "******", Email = "*****@*****.**" }; RegUser.Name = "Raúl"; RegUser.LastName = "González"; RegUser.User = "******"; RegUser.Email = "*****@*****.**"; RegUser.Password = "******"; //Act var resultado = RegUser.singIn(); //Assert Assert.IsTrue(resultado); }
public async Task <ActionResult> Create(SingIn model) { if (ModelState.IsValid) { if (model.singIn() == false) { ViewBag.Message = "El usuario o el email ya existen."; return(View("Create")); } else { return(RedirectToAction("Users")); } } return(View("Create")); }
public async Task <ActionResult> SingIn(SingIn datos) { if (ModelState.IsValid) { if (datos.singIn() == false) { ViewBag.Message = "El usuario o Email ya estan registrados."; return(View("SingIn", datos)); } else { return(RedirectToAction("Index", "Home")); } } else { return(View("SingIn")); } }
public ActionResult ResendVerificationEmail(SingIn singIn) { try { bool IsSendSccess = false; var checkUserIsActive = securityAreaBs.userBs.UserIsActive(singIn.forgetPassword.Email); if (checkUserIsActive.IsActive == false && checkUserIsActive.IsBlockByAdmin == false) { IsSendSccess = SendEmail(checkUserIsActive.UserId, checkUserIsActive.Email, checkUserIsActive.Name); if (IsSendSccess == true) { TempData["Msg"] = "Account activation link send to your registerd email id . Please check your inbox."; } else { TempData["Fail"] = "Account activation link send faild. Please contack to administrator"; } } else if (checkUserIsActive.IsActive == false && checkUserIsActive.IsBlockByAdmin == true) { TempData["Fail"] = "Your account is banned. Please contact to administrator."; } else if (checkUserIsActive.IsActive == true && checkUserIsActive.IsBlockByAdmin == true) { TempData["Fail"] = "Your account is banned. Please contact to administrator."; } return(RedirectToAction("ResendVerificationEmail", "Login", new { area = "Security" })); } catch (Exception ex) { TempData["Fail"] = "Some thing went wrong . Please contact to administrator." + ex; return(RedirectToAction("ResendVerificationEmail", "Login", new { area = "Security" })); throw; } }
public ActionResult UserLogin(SingIn singIn) { try { if (ModelState.IsValid) { var UserMembershipProvider = Membership.Providers["MyMembershipProvider"]; if (UserMembershipProvider.ValidateUser(singIn.login.Email, singIn.login.Password)) { var getUser = securityAreaBs.userBs.GetUserByEmail(singIn.login.Email); var getUserDetail = securityAreaBs.userBs.GetUserDetails(getUser.UserId); if (getUserDetail != null) { if (getUserDetail.Image != null && getUserDetail.ImageName != null && getUserDetail.ImageType != null) { CommanDetails profileImage = new CommanDetails(); profileImage.Image = getUserDetail.Image; profileImage.ImageName = getUserDetail.ImageName; profileImage.ImageType = getUserDetail.ImageType; Session["CNUserImage"] = profileImage; } else { Session["CNUserImage"] = null; } } Session[SessionObjects.CNUserId] = getUser.UserId; Session[SessionObjects.CNUserName] = getUser.Name; Session[SessionObjects.CNUserEmail] = getUser.Email; Session[SessionObjects.CNUserType] = Constant.USERTYPE.USER; FormsAuthentication.SetAuthCookie(singIn.login.Email, false); return(RedirectToAction("UserDashboard", "Dashboard", new { area = "UsersSection" })); } else { var getUserDetail = securityAreaBs.userBs.GetUserByEmail(singIn.login.Email); if (getUserDetail != null) { if (getUserDetail.IsActive == false && getUserDetail.IsBlockByAdmin == false) { TempData["Msg"] = "Please verify account before login. Verification link alredy send your registerd email id."; } else if (getUserDetail.IsActive == true && getUserDetail.IsBlockByAdmin == true) { TempData["Msg"] = "Your account is banned. Please contact to administrator."; } } return(RedirectToAction("Login", "Login", new { area = "Security" })); } } else { TempData["Msg"] = "Please enter email id or password."; return(RedirectToAction("Login", "Login", new { area = "Security" })); } } catch (Exception ex) { TempData["Msg"] = "Login failed " + ex; return(RedirectToAction("Login", "Login", new { area = "Security" })); } }