Exemple #1
0
 public AuthenticationCommandHandler(IUserService service, IMapper mapper, ITwoFactorAuthenticationService tfaService, IEmailService emailService)
 {
     _service      = service;
     _mapper       = mapper;
     _tfaService   = tfaService;
     _emailService = emailService;
 }
Exemple #2
0
 public GenerateUserAuthenticatorKeyCommandHandler(
     IMediator mediator,
     ITwoFactorAuthenticationService twoFactorAuthenticationService)
 {
     _mediator = mediator;
     _twoFactorAuthenticationService = twoFactorAuthenticationService;
 }
        public async Task <IActionResult> TwoFactorAuthorization([FromServices] ITwoFactorAuthenticationService twoFactorAuthenticationService)
        {
            if (!_customerSettings.TwoFactorAuthenticationEnabled)
            {
                return(RedirectToRoute("AdminLogin"));
            }

            var username = HttpContext.Session.GetString("AdminRequiresTwoFactor");

            if (string.IsNullOrEmpty(username))
            {
                return(RedirectToRoute("AdminLogin"));
            }

            var customer = _customerSettings.UsernamesEnabled ? await _customerService.GetCustomerByUsername(username) : await _customerService.GetCustomerByEmail(username);

            if (customer == null)
            {
                return(RedirectToRoute("AdminLogin"));
            }

            if (!customer.GetAttributeFromEntity <bool>(SystemCustomerAttributeNames.TwoFactorEnabled))
            {
                return(RedirectToRoute("AdminLogin"));
            }

            if (_customerSettings.TwoFactorAuthenticationType != TwoFactorAuthenticationType.AppVerification)
            {
                await twoFactorAuthenticationService.GenerateCodeSetup("", customer, _workContext.WorkingLanguage, _customerSettings.TwoFactorAuthenticationType);
            }

            return(View());
        }
 public AnwerTwoFactorAuthenticationCommandHandler(IMapper mapper, ITwoFactorAuthenticationService tfaService, IConfiguration configuration, IUserService userService, IUserRolService userRolService)
 {
     _mapper         = mapper;
     _tfaService     = tfaService;
     _userService    = userService;
     _conf           = configuration;
     _userRolService = userRolService;
 }
        public void Add(ITwoFactorAuthenticationService service)
        {
            if (service == null)
            {
                throw new ArgumentNullException(nameof(service));
            }

            _services.Add(service);
        }
Exemple #6
0
 public RegisterService(
     UserManager <DbPatient> userManager,
     UserManager <DbDoctor> doctorManager,
     ITwoFactorAuthenticationService twoFactorAuthenticationService)
 {
     _userManager   = userManager;
     _doctorManager = doctorManager;
     _twoFactorAuthenticationService = twoFactorAuthenticationService;
 }
 public GetTwoFactorAuthenticationHandler(
     ITwoFactorAuthenticationService twoFactorAuthenticationService,
     IMessageProviderService messageProviderService,
     CustomerSettings customerSetting)
 {
     _twoFactorAuthenticationService = twoFactorAuthenticationService;
     _messageProviderService         = messageProviderService;
     _customerSetting = customerSetting;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="AdminManageController"/> class.
 /// </summary>
 /// <param name="userManager"></param>
 /// <param name="urlEncoder"></param>
 /// <param name="twoFactorAuthenticationService"></param>
 /// <param name="optionsAccessor"></param>
 public AdminManageController(
     UserManager <User> userManager,
     UrlEncoder urlEncoder,
     ITwoFactorAuthenticationService twoFactorAuthenticationService,
     IOptions <EmOptions> optionsAccessor)
 {
     this.userManager = userManager;
     this.urlEncoder  = urlEncoder;
     this.twoFactorAuthenticationService = twoFactorAuthenticationService;
     this.options = optionsAccessor.Value;
 }
 public AccountController(
     ILoginService loginService,
     ITokenService tokenService,
     IRegisterService registerService,
     IMapper mapper,
     ITwoFactorAuthenticationService twoFactorAuthenticationService
     )
 {
     _loginService    = loginService;
     _tokenService    = tokenService;
     _registerService = registerService;
     _twoFactorAuthenticationService = twoFactorAuthenticationService;
     _mapper = mapper;
 }
 public LoginService(
     SignInManager <DbUser> signInManager,
     UserManager <DbUser> userManager,
     ITwoFactorAuthenticationService twoFactorAuthenticationService,
     IMapper mapper,
     IOptions <JwtIssuerOptions> jwtIssuerOptions,
     IUnitOfWork unitOfWork)
 {
     _signInManager = signInManager;
     _userManager   = userManager;
     _twoFactorAuthenticationService = twoFactorAuthenticationService;
     _mapper           = mapper;
     _jwtIssuerOptions = jwtIssuerOptions.Value;
     _unitOfWork       = unitOfWork;
 }
Exemple #11
0
 public ExternalController(
     IIdentityServerInteractionService interaction,
     IClientStore clientStore,
     IEventService events,
     IUsersService usersService,
     ILogger <ExternalController> logger,
     ITwoFactorAuthenticationService twoFactorAuthenticationService)
 {
     _interaction  = interaction;
     _clientStore  = clientStore;
     _events       = events;
     _usersService = usersService;
     _logger       = logger;
     _twoFactorAuthenticationService = twoFactorAuthenticationService;
 }
 public AccountController(
     IIdentityServerInteractionService interaction,
     IClientStore clientStore,
     IAuthenticationSchemeProvider schemeProvider,
     IEventService events,
     IUsersService usersService,
     ILogger <AccountController> logger,
     ITwoFactorAuthenticationService twoFactorAuthenticationService)
 {
     _usersService = usersService;
     _logger       = logger;
     _twoFactorAuthenticationService = twoFactorAuthenticationService;
     _interaction    = interaction;
     _clientStore    = clientStore;
     _schemeProvider = schemeProvider;
     _events         = events;
 }
        public async Task <IActionResult> TwoFactorAuthorization(string token,
                                                                 [FromServices] ITwoFactorAuthenticationService twoFactorAuthenticationService
                                                                 )
        {
            if (!_customerSettings.TwoFactorAuthenticationEnabled)
            {
                return(RedirectToRoute("AdminLogin"));
            }

            var username = HttpContext.Session.GetString("AdminRequiresTwoFactor");

            if (string.IsNullOrEmpty(username))
            {
                return(RedirectToRoute("HomePage"));
            }

            var customer = _customerSettings.UsernamesEnabled ? await _customerService.GetCustomerByUsername(username) : await _customerService.GetCustomerByEmail(username);

            if (customer == null)
            {
                return(RedirectToRoute("AdminLogin"));
            }

            if (string.IsNullOrEmpty(token))
            {
                ModelState.AddModelError("", _localizationService.GetResource("Account.TwoFactorAuth.SecurityCodeIsRequired"));
            }
            else
            {
                var secretKey = customer.GetAttributeFromEntity <string>(SystemCustomerAttributeNames.TwoFactorSecretKey);
                if (await twoFactorAuthenticationService.AuthenticateTwoFactor(secretKey, token, customer, _customerSettings.TwoFactorAuthenticationType))
                {
                    //remove session
                    HttpContext.Session.Remove("AdminRequiresTwoFactor");

                    //sign in
                    return(await SignInAction(customer, false));
                }
                ModelState.AddModelError("", _localizationService.GetResource("Account.TwoFactorAuth.WrongSecurityCode"));
            }

            return(View());
        }
 public GetTwoFactorAuthenticationHandler(ITwoFactorAuthenticationService twoFactorAuthenticationService, IWorkContext workContext)
 {
     _twoFactorAuthenticationService = twoFactorAuthenticationService;
     _workContext = workContext;
 }
 public GenerateUserRecoveryCodesCommandHandler(ITwoFactorAuthenticationService twoFactorAuthenticationService)
 {
     _twoFactorAuthenticationService = twoFactorAuthenticationService;
 }
 public GetUserRecoveryCodesCountQueryHandler(ITwoFactorAuthenticationService twoFactorAuthenticationService)
 {
     _twoFactorAuthenticationService = twoFactorAuthenticationService;
 }
Exemple #17
0
 public EnableUserAuthenticatorCommandHandler(ITwoFactorAuthenticationService twoFactorAuthenticationService)
 {
     _twoFactorAuthenticationService = twoFactorAuthenticationService;
 }
 public GetTwoFactorAuthenticationHandler(ITwoFactorAuthenticationService twoFactorAuthenticationService,
                                          CustomerSettings customerSetting)
 {
     _twoFactorAuthenticationService = twoFactorAuthenticationService;
     _customerSetting = customerSetting;
 }
 public DisableUserTwoFactorAuthenticationCommandHandler(ITwoFactorAuthenticationService twoFactorAuthenticationService)
 {
     _twoFactorAuthenticationService = twoFactorAuthenticationService;
 }
Exemple #20
0
 public GetUserAuthenticatorKeyQueryHandler(ITwoFactorAuthenticationService twoFactorAuthenticationService)
 {
     _twoFactorAuthenticationService = twoFactorAuthenticationService;
 }
 public UserController(IUserServices newUserServices, ITwoFactorAuthenticationService twoFactorAuthenticationService)
 {
     _newUserServices = newUserServices;
     _twoFactorAuthenticationService = twoFactorAuthenticationService;
 }
 public ResetUserAuthenticatorKeyCommandHandler(ITwoFactorAuthenticationService twoFactorAuthenticationService)
 {
     _twoFactorAuthenticationService = twoFactorAuthenticationService;
 }