public void GenerateFakeAuthUsers(IDbConnection connection, UserManager <ApplicationUser> userManager) { //http://stackoverflow.com/questions/22629936/no-iusertokenprovider-is-registered var ignodeEmails = MainUserRepository.GetEmails(); var users = userManager.Users.Where(u => !ignodeEmails.Contains(u.Email)); var pass = "******"; if (users.Any()) { return; } else { var count = 10; for (var i = 0; i < count; i++) { var username = FakeUserPrefix + i.ToString().PadLeft(5, '0'); var mail = username + "@gmail.com"; var user = new ApplicationUser { UserName = username, Email = mail }; var createdUser = _dbInitializer.CreateAppProgrammUser(userManager, user, pass).MakeSync(); if (createdUser == null || createdUser.EmailConfirmed) { continue; } _dbInitializer.AddUserToRoleIfNotExists(userManager, createdUser, new List <string> { MainRoles.Test }).MakeSync(); } } }
public async Task CreateMainUsersAndRolesIfNotExists(UserManager <ApplicationUser> userMamanger, RoleManager <IdentityRole> roleManager) { // создаем роли await CreateMainRolesIfNotExists(roleManager); //создаем пользователей //admin var admModel = MainUserRepository.GetAdminUser(); var adm = await _createMainUserIfNotExist(userMamanger, admModel.CreeateAsBase(), admModel.Password); await AddUserToRoleIfNotExists(userMamanger, adm, MainRoles.MainRolesList); //texture var textureModel = MainUserRepository.GetTextureUser(); var texture = await _createMainUserIfNotExist(userMamanger, textureModel.CreeateAsBase(), textureModel.Password); await AddUserToRoleIfNotExists(userMamanger, texture, new List <string> { MainRoles.Developer, MainRoles.Test, MainRoles.User, MainRoles.Guest }); //demoUser var demoModel = MainUserRepository.GetUser(MainUserRepository.DemoUserName); var demo = await _createMainUserIfNotExist(userMamanger, demoModel.CreeateAsBase(), demoModel.Password); await AddUserToRoleIfNotExists(userMamanger, demo, new List <string> { MainRoles.User, MainRoles.Guest }); }
public MainInitializer(IAllianceInitializer allianceInitializer, IMapGInitializer mapGInitializer, IAuthUsersInitializer authUsersInitializer, IGameUserService gameUserService, INpcInitializer npcInitializer, IUserInitializer userInitializer, IUserNameSercherPkCache userNameSercherPkCache, IUserLocalStorageCache userCache, IUserRepository userRepo, IAllianceService allianceService, IChannelService channelService, IDbProvider provider) { _allianceInitializer = allianceInitializer; _mapGInitializer = mapGInitializer; _authUsersInitializer = authUsersInitializer; _gameUserService = gameUserService; _npcInitializer = npcInitializer; _userInitializer = userInitializer; _userNameSercherPkCache = userNameSercherPkCache; _userCache = userCache; _userRepo = userRepo; _allianceService = allianceService; _provider = provider; _channelService = (ChannelService)channelService; _admUser = MainUserRepository.GetAdminUser(); _textUser = MainUserRepository.GetTextureUser(); _demoUser = MainUserRepository.GetUser(MainUserRepository.DemoUserName); }
private bool _fillCache(ApplicationDbContext context) { var mu = MainUserRepository.MainUserNames; var t = context.Users.Where(i => mu.Contains(i.UserName)); var mainUsers = t.ToList(); foreach (var mainUser in mainUsers) { MainUserRepository.Update(mainUser); } return(true); }
private async Task <ApplicationUser> _createMainUserIfNotExist(UserManager <ApplicationUser> userMamanger, ApplicationUser importantUser, string password) { var before = importantUser.ToSerealizeString(); var created = await CreateAppProgrammUser(userMamanger, importantUser, password); var after = created.ToSerealizeString(); if (before != after) { MainUserRepository.Update(created); } return(created); }
public void ResetAdminPlanets(IDbConnection connection) { var admin = MainUserRepository.GetAdminUser(); if (admin.GameId == 0) { throw new ArgumentNullException(nameof(admin.GameId), "GameId not set in instance"); } _updatePlanetList(connection, _gDetailPlanetService.GetUserPlanets(connection, admin.GameId), i => SetInitialPlanetBuilds(i, admin.GameId)); ResetMotherResourceById(connection, admin.GameId); }
public AllianceDataModel CreateBaseAlliance(IDbConnection connection) { var admin = MainUserRepository.GetAdminUser(); var allianceName = "Time killer"; return(_allianceService.CreateAlliance(connection, new AllianceDataModel { Name = allianceName, Description = MainInitializer.APref + allianceName + MainInitializer.ADescription, DateCreate = DateTime.UtcNow, CreatorName = admin.NikName, CreatorId = admin.GameId, Images = Label.DefaultUrls(), Tax = 13, Cc = 99999 })); }
private void ConfigureStaticClases(IServiceCollection services) { //main users //email test sender method if (!_isDevelopment) { throw new NotImplementedException("ConfigureStaticClases:Check you secrets, configure it and uncommit that row wen all be ready"); } // get user data from your secrets EmailSenderExtensions.EmailForTesting = Configuration.GetSection("EmailSenderEmailForTesting").Value; #region Azure storages and services /* throw error because need exist storages, now all storages did removed. that code only for example * if you create different azure storage name and run client side with use cdn parameters, * check cdn name in client side, that name using for building path to model and textures */ var storages = new Dictionary <AzureStorageConnectionType, AzureStorageConnectionConfigurationModel>(); storages.Add(AzureStorageConnectionType.SkagryUserImages, new AzureStorageConnectionConfigurationModel { AccountKeyValue = "Oaa3AzRtkI8ecJTiPdMLFY2bKG+lXCSKMf8w7ef6i729vMbu6WbLGKcL9AU4lw2CTirXYnYsVith8ZMw3n6n7g==", AccountName = "skagryuserimages", Type = AzureStorageConnectionType.SkagryUserImages }); storages.Add(AzureStorageConnectionType.EternPlayPublic, new AzureStorageConnectionConfigurationModel { AccountKeyValue = "b8CSupsGRgX6f04zr++zZxgPh2zbrODckVh7eIuGne9bB6bjVOcTl9anQ+FN7GZwtDlePc5DYKRI/fQbBOHfHQ==", AccountName = "eternplaypublic", Type = AzureStorageConnectionType.EternPlayPublic }); storages.Add(AzureStorageConnectionType.SkagryLogErrors, new AzureStorageConnectionConfigurationModel { AccountKeyValue = "2pf69mSxhrSvk/99msSDrImiQVoOpZzz+uA6fu/iOp8e7TvxqsHhAFDUyr6P4vMeCMV6ZPyJtUnXHhspUOHv7g==", AccountName = "skagrylogerrors", Type = AzureStorageConnectionType.SkagryLogErrors }); AzureStorageConnectionNames.ConfigureAzureStorageConnections(storages); AzureLogCdnData.ConfigureAzureLogCdnData(Configuration.GetSection("AzureLogCdnUrl").Value); //falset config to local version Label.ConfigureLabel(false); Avatar.ConfigureAvatar(false); #endregion #region Configure MainUserRepository // todo if users are not existing, will be generated with that parameters and be save in databases (auth and game databases) // first ids reserved for nps ids, so put game id more than 1000, default 1000,1001,1002 game ids if they are not exist var users = Configuration.GetSection("MainUsers").Get <MainUserConfigModel[]>(); if (users != null && users.Length > 0) { MainUserRepository.ConfigureMainUserRepository(users); } else { //uncomment it //throw new NotImplementedException("MainUsers doesnt set in secrets"); } #endregion }