public RepositoryFactory(IOptions <WordzzSettings> settings, ILogger logger) { _settings = settings.Value; _logger = logger; _repositoryType = (RepositoryType)Enum.Parse(typeof(RepositoryType), _settings.Db.DbType); }
public SessionService(ILogger log, ISessionRepository sessionRepository, IUserRepository userRepository, IOptions <WordzzSettings> settings) { this.log = log; this.userRepository = userRepository; this.sessionRepository = sessionRepository; this.settings = settings.Value; sessionCheckTimer = new Timer(new TimerCallback(SessionCheckTimerCallback)); sessionCheckTimer.Change(5 * 1000, -1); }
internal static async Task ValidateAdminUser(this IApplicationBuilder app, ILogger log, WordzzSettings wsettings) { var serviceProvider = app.ApplicationServices; var userRepository = serviceProvider.GetService <IUserRepository>(); var admin = await userRepository.Get("sa"); if (admin != null) { return; } var user = new User { UserName = "******", CreationDate = DateTime.UtcNow, Deleted = false }; var withPassword = user.SetPassword("#Na123@10", wsettings.EncryptionKey); var added = await userRepository.Add(withPassword, "*****@*****.**"); var details = new UserDetails { UserName = added.UserName, Address = "Famalicão", City = "Vila Nova de Famalição", Country = "Portugal", Email = "*****@*****.**", FirstName = "Server", LastName = "Admin", PostalCode = "4760" }; var addedDetails = await userRepository.UpdateDetails(details); var settings = new UserSettings { UserName = addedDetails.UserName, MainSettings = new MainSettings { UserId = addedDetails.UserName, DefaultBoard = 1, Language = "en-us" }.ToJson(), WindowsSettings = new WindowsSettings { UserId = addedDetails.UserName }.ToJson(), AndroidSettings = new AndroidSettings { UserId = addedDetails.UserName }.ToJson(), IOSSettings = new IOSSettings { UserId = addedDetails.UserName }.ToJson() }; await userRepository.UpdateSettings(settings); await log.WarningAsync("Added server admin user"); }
public DictionaryApiFactory(IOptions <WordzzSettings> settings, ILogger log) { this.settings = settings.Value; this.log = log; }