public async Task <ActionResult> OnlyEmail(OnlyEmailViewModel data)
        {
            string key = CollectionOfMethods.GetHashString(data.Email);

            if (ModelState.IsValid)
            {
                ResetPassword newData = new ResetPassword()
                {
                    Id     = 4,
                    UserId = repoReset.GetUserWithEmail(data.Email).Id,
                    Key    = key,
                };
                repoReset.Save(newData);
                EmailService emailService = new EmailService();
                await emailService.SendEmailAsync(data.Email, @Resources.Web.ChangePasswordTheme,
                                                  TemplateForEmail.ForgotPassword(Url.Action("ResetPassword", "Account", new { Key = key }, Request.Url.Scheme)));

                return(RedirectToAction("WaitingForConfirm"));
            }
            else
            {
                //             Response.StatusCode = (int) HttpStatusCode.BadRequest;
                return(View(data));
            }
        }
        public async Task <ActionResult> Registration(RegisteViewModel registerData)
        {
            if (ModelState.IsValid)
            {
                if (repo.CheckEmailUniqueness(registerData.Email) == false)
                {
                    ModelState.AddModelError("", @Resources.Web.MailBusy);

                    return(PartialView(registerData));
                }
                string key = CollectionOfMethods.GetHashString(registerData.Email) + CollectionOfMethods.GetHashString(registerData.Name);
                UserForConfirmedEmail newUser = new UserForConfirmedEmail()
                {
                    Key   = key,
                    Email = registerData.Email,
                    User  = new User()
                    {
                        Name         = registerData.Name,
                        PasswordHash = CollectionOfMethods.GetHashString(registerData.Password),
                        Email        = registerData.Email,
                        Date         = DateTime.UtcNow,
                        Confirmed    = false
                    }
                };
                repoForEmail.Save(newUser);
                EmailService emailService = new EmailService();
                await emailService.SendEmailAsync(registerData.Email, @Resources.Web.ConfirmEmailTheme,
                                                  TemplateForEmail.Registration(Url.Action("ConfirmEmail", "Account", new { Key = key }, Request.Url.Scheme)));

                return(Json(new { successful = true }));
                //  return View("WaitingForConfirm");
            }

            return(PartialView(registerData));
        }
        public ActionResult SignIn(AuthorizationViewModel authorizationUser)
        {
            User user = repo.GetAuthorizateUser(authorizationUser.Name,
                                                CollectionOfMethods.GetHashString(authorizationUser.Password));

            if (ModelState.IsValid)
            {
                if (user != null)
                {
                    if (user.Confirmed)
                    {
                        FormsAuthentication.SetAuthCookie(user.Email, true);
                        return(Json(new { responceMessage = "successful" }));
                        //return RedirectToAction("Index", "Home");
                    }
                    return(Json(new { responceMessage = "emailNotConfirmed" }));
                    //return PartialView("~/Views/Account/PleaseConfirmedEmail.cshtml");
                }
                else
                {
                    ModelState.AddModelError("", Resources.Web.NoSuchUser);
                }
                return(PartialView(authorizationUser));
            }

            return(PartialView(authorizationUser));
        }
 public ActionResult ResetPassword(ResetPasswordViewModel model)
 {
     if (ModelState.IsValid)
     {
         if (User.Identity.IsAuthenticated)
         {
             repoReset.UpdateWithEmail(User.Identity.Name, CollectionOfMethods.GetHashString(model.Password));
             repoReset.DeleteResetKey(model.Key);
             deleteCookieAuth();
             return(RedirectToAction("SignIn", "Account", new { message = Resources.Web.ChangePasswordIsSuccesfull }));
         }
         else
         {
             repoReset.UpdatePasswordWithKey(model.Key, CollectionOfMethods.GetHashString(model.Password));
             repoReset.DeleteResetKey(model.Key);
             return(RedirectToAction("SignIn", "Account", new { message = Resources.Web.ChangePasswordIsSuccesfull }));
         }
     }
     //          Response.StatusCode = (int) HttpStatusCode.BadRequest;
     return(View(model));
 }