コード例 #1
0
        public ApplicationUserManager(IUserStore <ApplicationUser, int> store, IProfileAppService profileAppService, IUserAppService userAppService, IAccessAppService accessAppService, IParameterAppService parameterAppService)
            : base(store)
        {
            _profileAppService   = profileAppService;
            _userAppService      = userAppService;
            _accessAppService    = accessAppService;
            _parameterAppService = parameterAppService;

            //Username validation config
            UserValidator = new UserValidator <ApplicationUser, int>(this)
            {
                AllowOnlyAlphanumericUserNames = false,
                RequireUniqueEmail             = true
            };

            PasswordValidator = new CustomPasswordValidator()
            {
                RequiredLength          = 6,
                RequireNonLetterOrDigit = true,
                RequireDigit            = true,
                RequireLowercase        = true,
                RequireUppercase        = true,
            };

            //Lockout Configuaration
            UserLockoutEnabledByDefault          = true;
            DefaultAccountLockoutTimeSpan        = TimeSpan.FromMinutes(5);
            MaxFailedAccessAttemptsBeforeLockout = 5;

            // Providers to Two Factor Autentication
            RegisterTwoFactorProvider("Código via SMS", new PhoneNumberTokenProvider <ApplicationUser, int>
            {
                MessageFormat = "Seu código de segurança é: {0}"
            });

            RegisterTwoFactorProvider("Código via E-mail", new EmailTokenProvider <ApplicationUser, int>
            {
                Subject    = "Código de Segurança",
                BodyFormat = "Seu código de segurança é: {0}"
            });

            //E-mail service class Config
            EmailService = new MailService(_parameterAppService);


            var provider      = new DpapiDataProtectionProvider("Earth");
            var dataProtector = provider.Create("EmailConfirmation");

            UserTokenProvider = new DataProtectorTokenProvider <ApplicationUser, int>(dataProtector);
        }
コード例 #2
0
 public AccessController(ILogger <AccessController> logger,
                         IAccessAppService accessAppService) : base(logger)
 {
     this.accessAppService = accessAppService;
 }