public AuthenticationService(IJwtService jwtService, IDalRepository <Account> dal, IDalRepository <AccountLoginHistory> loginHistory, WebHelper helper, IUserCachingService userCachingService, IDalRepository <Rule> ruleDal)
 {
     _dal                = dal;
     _loginHistory       = loginHistory;
     _helper             = helper;
     _userCachingService = userCachingService;
     _ruleDal            = ruleDal;
     _jwtService         = jwtService;
 }
        public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config)
        {
            //
            // Initialize values from web.config.
            //

            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            if (name == null || name.Length == 0)
            {
                name = "LightweightMembershipProvider";
            }

            if (String.IsNullOrEmpty(config["description"]))
            {
                config.Remove("description");
                config.Add("description", "Lightweight Linq to Entities membership provider");
            }

            // Initialize the abstract base class.
            base.Initialize(name, config);

            pApplicationName = config["applicationName"] ??
                               System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath;
            pMaxInvalidPasswordAttempts           = Convert.ToInt32(config["maxInvalidPasswordAttempts"] ?? "5");
            pPasswordAttemptWindow                = Convert.ToInt32(config["passwordAttemptWindow"] ?? "10");
            pMinRequiredNonAlphanumericCharacters = Convert.ToInt32(config["minRequiredNonAlphanumericCharacters"] ?? "1");
            pMinRequiredPasswordLength            = Convert.ToInt32(config["minRequiredPasswordLength"] ?? "7");
            pPasswordStrengthRegularExpression    = Convert.ToString(config["passwordStrengthRegularExpression"] ?? "");
            pEnablePasswordReset       = Convert.ToBoolean(config["enablePasswordReset"] ?? "true");
            pEnablePasswordRetrieval   = Convert.ToBoolean(config["enablePasswordRetrieval"] ?? "true");
            pInitPassword              = Convert.ToString(config["initPassword"]);
            pRequiresQuestionAndAnswer = Convert.ToBoolean(config["requiresQuestionAndAnswer"] ?? "false");
            pRequiresUniqueEmail       = Convert.ToBoolean(config["requiresUniqueEmail"] ?? "true");
            pWriteExceptionsToEventLog = Convert.ToBoolean(config["writeExceptionsToEventLog"] ?? "true");

            string temp_format = config["passwordFormat"];

            if (temp_format == null)
            {
                temp_format = "Hashed";
            }

            switch (temp_format)
            {
            case "Hashed":
                pPasswordFormat = MembershipPasswordFormat.Hashed;
                break;

            case "Encrypted":
                pPasswordFormat = MembershipPasswordFormat.Encrypted;
                break;

            case "Clear":
                pPasswordFormat = MembershipPasswordFormat.Clear;
                break;

            default:
                throw new ProviderException("Password format not supported.");
            }

            Assembly siteAssembly = L24Manager.ControllerAssembly;
            string   localUserObjectContextType = config["localUserObjectContextType"];

            if (!string.IsNullOrEmpty(localUserObjectContextType))
            {
                UserObjectContextType = siteAssembly.GetType(localUserObjectContextType);
            }
            string localUserType = config["localUserType"];

            if (!string.IsNullOrEmpty(localUserType))
            {
                UserType = siteAssembly.GetType(localUserType);
            }
            string userCachingServiceType = config["userCachingServiceType"];

            if (!string.IsNullOrEmpty(userCachingServiceType))
            {
                Type ucsType = this.GetType().Assembly.GetType(userCachingServiceType)
                               ?? siteAssembly.GetType(userCachingServiceType);
                if (ucsType != null)
                {
                    userCachingService = Activator.CreateInstance(ucsType) as IUserCachingService;
                }
            }


            // Get encryption and decryption key information from the configuration.
            Configuration cfg =
                WebConfigurationManager.OpenWebConfiguration(System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath);

            machineKey = (MachineKeySection)cfg.GetSection("system.web/machineKey");

            if (machineKey.ValidationKey.Contains("AutoGenerate"))
            {
                if (PasswordFormat != MembershipPasswordFormat.Clear)
                {
                    throw new ProviderException("Hashed or Encrypted passwords " +
                                                "are not supported with auto-generated keys.");
                }
            }
        }