public UserDetailsVm Login(LoginDetails loginDetails) { UserDetail userDetails = new UserDetail(); using (GrowUpIncubatorEntities db = new GrowUpIncubatorEntities()) { userDetails = db.UserDetails.Where(x => x.UserName.Equals(loginDetails.UserName, StringComparison.OrdinalIgnoreCase) && x.Password == loginDetails.Password).FirstOrDefault(); } UserDetailsVm userDetailsVm = new UserDetailsVm(); if (userDetails != null) { userDetailsVm = new UserDetailsVm() { Id = userDetails.Id, UserName = userDetails.UserName, Password = string.Empty, RoleType = userDetails.RoleType } } ; else { userDetailsVm = null; } return(userDetailsVm); }
public async Task <ActionResult> EditLogin(UserDetailsVm user) { var op = _userService.EditLoginInformations(user.Id, user.Email); if (op.Succedeed) { if (!String.IsNullOrWhiteSpace(user.Password) && !String.IsNullOrWhiteSpace(user.ConfirmPassword)) { if (user.Password != user.ConfirmPassword) { return(Json(new { Succedeed = false, message = "كلمة المرور وتأكيدها غير متطابقتان", prop = op.Property })); } String hashedNewPassword = UserManager.PasswordHasher.HashPassword(user.Password); var result = await UserManager.ChangePassword(UserManager.Users.ToList().Where(c => c.Id == user.Id).FirstOrDefault(), hashedNewPassword); if (result) { return(Json(new { Succedeed = op.Succedeed, message = op.Message, prop = op.Property })); } else { return(Json(new { Succedeed = false, message = "لم يتم تغيير كلمة المرور" })); } } return(Json(new { Succedeed = true, message = "تم تغيير البريد الالكتروني", prop = op.Property })); } return(Json(new { Succedeed = op.Succedeed, message = op.Message, prop = op.Property })); }
public ActionResult LockAccount(UserDetailsVm user) { //var result = await UserManager.SetLockoutEnabledAsync(user.Id, true); //if (result.Succeeded) // return Json(new { Succedeed = true, message = "تم قفل الحساب " }); OperationDetails op = _userService.LockUser(user.Id, true); return(Json(new { Succedeed = op.Succedeed, message = op.Message, op.Property })); }
public ActionResult EditPersonal(UserDetailsVm user) { if (ModelState.IsValid) { var op = _userService.EditPersonalInformations(user.Id, user.FirstName, user.LastName); return(Json(new { Succedeed = op.Succedeed, message = op.Message, prop = op.Property })); } else { return(View("Edit", user)); } }
public async Task <ActionResult> ResendConfirmationEmail(UserDetailsVm user) { var code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); string email = Utils.buildUserConfirmEmail(callbackUrl); await UserManager.SendEmailAsync(user.Id, "Confirmation", email); return(Json(new { Succedeed = true, message = "تمت عملية الارسال بنجاح" })); }