Exemplo n.º 1
0
        public ActionResult DeleteCertificateHub(string certificateIdentificator, string returnUrl)
        {
            if (!string.IsNullOrWhiteSpace(certificateIdentificator))
            {
                var user          = _context.userRepository.GetUserByEmail(this.User.Identity.Name);
                var generatedCode = _keyGenerator.GenerateUserTokenForEntityDeletion(user);

                var url          = Url.DeleteCertificateEntityLink(certificateIdentificator, generatedCode, Request.Scheme);
                var emailMessage = _emailSender.GenerateEmailMessage(user.Email, user.FirstName + " " + user.LastName, "authorizeAction", url);
                _emailSender.SendEmailAsync(emailMessage);

                return(RedirectToAction("UniversalConfirmationPanel", "Account", new { messageNumber = 5, returnUrl }));
            }

            return(RedirectToAction("BlankMenu", "Certificates"));
        }
Exemplo n.º 2
0
        public async Task <ActionResult> Login(LoginViewModel model, string returnUrl = null)
        {
            ViewData["ReturnUrl"] = returnUrl;

            if (ModelState.IsValid)
            {
                var user = _userManager.FindByEmailAsync(model.Email).Result;

                if (user != null)
                {
                    var emailConfirmed = _userManager.IsEmailConfirmedAsync(user).Result;

                    if (!emailConfirmed)
                    {
                        ModelState.AddModelError(string.Empty, "Adres email przypisany do konta nie został potwierdzony. Sprawdź swoją skrzynkę pocztową - wysłaliśmy wiadomość w celu potwierdzenia Twojego adresu email.");

                        var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);

                        var callbackUrl = Url.EmailConfirmationLink(user.Id, code, Request.Scheme);

                        var emailToSend = _emailSender.GenerateEmailMessage(model.Email, user.FirstName + " " + user.LastName, "emailConfirmation", callbackUrl);
                        await _emailSender.SendEmailAsync(emailToSend);

                        #region UserLoginLog

                        var logInfoUserLogin = _logger.GenerateUserLoginInformation(user.Email, UserLoginActionStatus.UserLoginStatus[2]);
                        _logger.AddUserLoginLog(logInfoUserLogin);

                        #endregion

                        return(View(model));
                    }
                }

                var result = await _signInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, lockoutOnFailure : false);

                if (result.Succeeded)
                {
                    #region UserLoginLog

                    var logInfoUserLogin = _logger.GenerateUserLoginInformation(user.Email, UserLoginActionStatus.UserLoginStatus[0]);
                    _logger.AddUserLoginLog(logInfoUserLogin);

                    #endregion

                    return(RedirectToLocal(returnUrl));
                }
                else
                {
                    ModelState.AddModelError(string.Empty, "Adres email lub hasło są błędne.");

                    #region UserLoginLog

                    var logInfoUserLogin = _logger.GenerateUserLoginInformation("", UserLoginActionStatus.UserLoginStatus[1]);
                    _logger.AddUserLoginLog(logInfoUserLogin);

                    #endregion

                    return(View(model));
                }
            }

            return(View(model));
        }