Exemple #1
0
        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);
        }