public IActionResult Activation(string key)
        {
            string output = new Helpers.AESEncryption().DecryptText(key);

            string[]   tokens     = output.Split(":OSK:");
            EmailValid emailValid = _activationService.GetByFilter(i => i.Email == tokens[0] && i.ActivationKey == tokens[2] && DateTime.Parse(i.Time.ToString()) == DateTime.Parse(tokens[1]));

            if (emailValid != null)
            {
                if (DateTime.Now > DateTime.Parse(tokens[1]).AddDays(1))
                {
                    return(RedirectToAction("EmailValidExpired", "Alert"));
                }
                _activationService.Delete(emailValid);
                CryptoBox.Data.Models.Users user = _userService.GetByFilter(i => emailValid.Email == i.Email);
                user.EmailValid = true;
                _userService.UpdateUser(user);
                return(RedirectToAction("EmailValidSuccess", "Alert"));
            }
            return(RedirectToAction("EmailValidFailed", "Alert"));
        }
        public async Task <ActionResult> Login(LoginViewModel model)
        {
            if (ModelState.IsValid)
            {
                CryptoBox.Data.Models.Users user = _userService.GetByFilter(i => i.Email == model.Email && i.Password == new PasswordEncode().Encoder(model.Password));
                if (user == null)
                {
                    TempDataMessage("message", "danger", $"Incorrect Password or Email.");
                    return(RedirectToAction("Index", "Home"));
                }
                else
                {
                    if (!user.EmailValid)
                    {
                        TempDataMessage("message", "danger", $"Account is not valid ({user.Email}),please active it");
                        return(RedirectToAction("Index", "Home"));
                    }
                    var identity = new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, user.Id.ToString()), new Claim("Email", user.Email) }, CookieAuthenticationDefaults.AuthenticationScheme);

                    await HttpContext.SignOutAsync();

                    await HttpContext.SignInAsync(new ClaimsPrincipal(identity),
                                                  new AuthenticationProperties
                    {
                        IsPersistent = true,
                        ExpiresUtc   = DateTimeOffset.MaxValue,
                        AllowRefresh = true
                    });
                }
            }
            else
            {
                TempDataMessage("message", "danger", $"Login form datas is not valid");
                return(RedirectToAction("Index", "Home"));
            }
            return(RedirectToAction("Index", "Home"));
        }