예제 #1
0
        /// <summary>
        /// Login to PokémonGo and return an authenticated <see cref="ClientSession" />.
        /// </summary>
        /// <param name="loginProvider">Provider must be PTC or Google.</param>
        /// <param name="initLat">The initial latitude.</param>
        /// <param name="initLong">The initial longitude.</param>
        /// <param name="mayCache">Can we cache the <see cref="AccessToken" /> to a local file?</param>
        private async Task <Session> GetSession(ILoginProvider loginProvider, double initLat, double initLong, bool mayCache = false)
        {
            LoginProvider = loginProvider;

            Session session = null;

            if (mayCache)
            {
                var cacheDir = Path.Combine(Directory.GetCurrentDirectory(), "Cache");
                var fileName = Path.Combine(cacheDir, $"{loginProvider.UserId}-{loginProvider.ProviderId}.json");

                if (!Directory.Exists(cacheDir))
                {
                    Directory.CreateDirectory(cacheDir);
                }

                if (File.Exists(fileName))
                {
                    var accessToken = JsonConvert.DeserializeObject <AccessToken>(File.ReadAllText(fileName));

                    if (accessToken != null || !string.IsNullOrEmpty(accessToken.Token) || !accessToken.IsExpired)
                    {
                        session = await Login.GetSession(loginProvider, accessToken, initLat, initLong, ClientDeviceWrapper, PlayerLocale);

                        LoadResources(session);
                        return(session);
                    }
                }
            }

            session = await Login.GetSession(loginProvider, initLat, initLong, ClientDeviceWrapper, PlayerLocale);

            LoadResources(session);
            return(session);
        }
예제 #2
0
파일: Login.cs 프로젝트: PeterDM65/POGOLib
        /// <summary>
        /// Login with a stored <see cref="AccessToken" />.
        /// </summary>
        /// <param name="loginProvider">The OAuth provider you use to authenticate.</param>
        /// <param name="accessToken">The <see cref="AccessToken"/> you want to re-use.</param>
        /// <param name="coordinate">The initial coordinate you will spawn at after logging into PokémonGo.</param>
        /// <param name="deviceWrapper">The <see cref="DeviceWrapper"/> used by the <see cref="Session"/>, keep null if you want a randomly generated <see cref="DeviceWrapper"/>.</param>
        /// <param name = "playerLocale"></param>
        /// <returns></returns>
        public static Session GetSession(ILoginProvider loginProvider, AccessToken accessToken, GeoCoordinate coordinate, DeviceWrapper deviceWrapper = null, GetPlayerMessage.Types.PlayerLocale playerLocale = null)
        {
            DeviceWrapper device = deviceWrapper ?? DeviceInfoUtil.GetRandomDevice();

            GetPlayerMessage.Types.PlayerLocale locale = playerLocale ?? new GetPlayerMessage.Types.PlayerLocale {
                Country = "US", Language = "en", Timezone = "America/New_York"
            };
            string language = locale.Language + "-" + locale.Country;

            if (accessToken.IsExpired)
            {
                accessToken = loginProvider.GetAccessToken(device.UserAgent, language).Result;
                //throw new ArgumentException($"{nameof(accessToken)} is expired.");
            }

            var session = new Session(loginProvider, accessToken, coordinate, device, locale);

            session.Logger.Debug("Authenticated from cache.");
            if (loginProvider is PtcLoginProvider)
            {
                session.Logger.Debug("Authenticated through PTC.");
            }
            else
            {
                session.Logger.Debug("Authenticated through Google.");
            }
            return(session);
        }
예제 #3
0
        /// <summary>
        /// Login to PokémonGo and return an authenticated <see cref="Session" />.
        /// </summary>
        /// <param name="loginProvider">Provider ID must be 'PTC' or 'Google'.</param>
        /// <param name="initLat">The initial latitude.</param>
        /// <param name="initLong">The initial longitude.</param>
        /// <param name="mayCache">Can we cache the <see cref="AccessToken" /> to a local file?</param>
        private static async Task <Session> GetSession(ILoginProvider loginProvider, double initLat, double initLong, bool mayCache = false)
        {
            var cacheDir = Path.Combine(Directory.GetCurrentDirectory(), "Cache");
            var fileName = Path.Combine(cacheDir, $"{loginProvider.UserId}-{loginProvider.ProviderId}.json");

            if (mayCache)
            {
                if (!Directory.Exists(cacheDir))
                {
                    Directory.CreateDirectory(cacheDir);
                }

                if (File.Exists(fileName))
                {
                    var accessToken = JsonConvert.DeserializeObject <AccessToken>(File.ReadAllText(fileName));

                    if (!accessToken.IsExpired)
                    {
                        return(Login.GetSession(loginProvider, accessToken, initLat, initLong));
                    }
                }
            }

            var session = await Login.GetSession(loginProvider, initLat, initLong);

            if (mayCache)
            {
                SaveAccessToken(session.AccessToken);
            }

            return(session);
        }
예제 #4
0
        async Task <bool> IsUserRegisteredInTheCloud(ILoginProvider loginProvider)
        {
            ICloudTable <UserDetails> Table = GetTable <UserDetails>();
            string  tableId = loginProvider.RetrieveTableIdFromSecureStore();
            Account account = loginProvider.RetreiveAccountFromSecureStore();

            if (tableId == null)
            {
                ICollection <UserDetails> tempUserDetailsList = await Table.ReadAllItemsAsync();

                UserDetails userDetails = tempUserDetailsList.FirstOrDefault(x => x.userId == client.CurrentUser.UserId);
                account.Properties.Add("table_id", userDetails.Id);
                loginProvider.SaveAccountInSecureStore(account);
                App.UserDetails = userDetails;
            }
            else
            {
                UserDetails tempUserDetails = await Table.ReadItemAsync(tableId);

                App.UserDetails = tempUserDetails;
            }

            if (App.UserDetails != null)
            {
                return(true);
            }
            return(false);
        }
예제 #5
0
        private static async Task <AccessToken> LoadAccessToken(ILoginProvider loginProvider, Client client, bool mayCache = false)
        {
            var cacheDir = Path.Combine(Directory.GetCurrentDirectory(), "Cache");
            var fileName = Path.Combine(cacheDir, $"{loginProvider.UserId}-{loginProvider.ProviderId}.json");

            if (mayCache)
            {
                if (!Directory.Exists(cacheDir))
                {
                    Directory.CreateDirectory(cacheDir);
                }

                if (File.Exists(fileName))
                {
                    var accessToken = JsonConvert.DeserializeObject <AccessToken>(File.ReadAllText(fileName));

                    if (!accessToken.IsExpired)
                    {
                        client.AccessToken = accessToken;
                        return(accessToken);
                    }
                }
            }

            await Reauthenticate(client);

            if (mayCache)
            {
                SaveAccessToken(client.AccessToken);
            }

            return(client.AccessToken);
        }
예제 #6
0
        public void OnLoginStateChanged(object sender, LoginStateEventArgs e)
        {
            if (controller == null)
            {
                return;
            }
            if (e.Code == LoginState.LOGINNING)
            {
                controller.SetTitle(LanguageManager.Model.LoginLogIn);
            }
            else if (e.Code == LoginState.GETTING_DATA)
            {
                controller.SetTitle(LanguageManager.Model.LoginGettingData);
            }
            string message = string.Format(LanguageManager.Model.LoginTry, e.AttemptNumber);

            if (e.LastError != -1)
            {
                message += string.Format(" ({0} {1})", LanguageManager.Model.LoginWasError, e.LastError);
            }
            controller.SetMessage(message);

            if (controller.IsCanceled)
            {
                ILoginProvider loginProvider = sender as ILoginProvider;
                if (loginProvider != null)
                {
                    loginProvider.CancelLogin();
                }
            }
        }
예제 #7
0
 public HomeController(ISeverityProvider severityProvider, ILoginProvider loginProvider, IUserProvider provider, IChecklistProvider checklistProvider)
 {
     _severityProvider  = severityProvider;
     _loginProvider     = loginProvider;
     _provider          = provider;
     _checklistProvider = checklistProvider;
 }
예제 #8
0
        /// <summary>
        /// Login with a stored <see cref="AccessToken" />.
        /// </summary>
        /// <param name="loginProvider">The OAuth provider you use to authenticate.</param>
        /// <param name="accessToken">The <see cref="AccessToken"/> you want to re-use.</param>
        /// <param name="coordinate">The initial coordinate you will spawn at after logging into UniteGo.</param>
        /// <param name="deviceWrapper">The <see cref="DeviceWrapper"/> used by the <see cref="Session"/>, keep null if you want a randomly generated <see cref="DeviceWrapper"/>.</param>
        /// <param name = "playerLocale"></param>
        /// <returns></returns>
        public static async Task <Session> GetSession(ILoginProvider loginProvider, AccessToken accessToken, GeoCoordinate coordinate, DeviceWrapper deviceWrapper = null, CreateOrUpdatePlayerMessage.Types.ClientPlayerLocale playerLocale = null)
        {
            DeviceWrapper device = deviceWrapper ?? DeviceInfoUtil.GetRandomDevice();

            CreateOrUpdatePlayerMessage.Types.ClientPlayerLocale locale = playerLocale ?? new CreateOrUpdatePlayerMessage.Types.ClientPlayerLocale {
                Country = "US", Language = "en", Timezone = "America/New_York"
            };
            string language = locale.Language + "-" + locale.Country;

            if (accessToken == null || string.IsNullOrEmpty(accessToken.Token) || accessToken.IsExpired)
            {
                accessToken = await loginProvider.GetAccessToken(device.UserAgent, language);

                if (accessToken == null || string.IsNullOrEmpty(accessToken.Token) || accessToken.IsExpired)
                {
                    throw new SessionStateException($"{nameof(accessToken)} is expired.");
                }
            }

            var session = new Session(loginProvider, accessToken, coordinate, device, locale);

            session.Logger.Debug("Authenticated from cache.");
            session.Logger.Debug("Authenticated through Google.");
            return(session);
        }
예제 #9
0
 public FamiliesController(IDataRepository dataRepository, ILoginProvider loginProvider,
                           IImageService imageService, ILogger <FamiliesController> logger) : base(dataRepository)
 {
     _loginProvider = loginProvider;
     _imageService  = imageService;
     _logger        = logger;
 }
예제 #10
0
 public ContactSummariesHub(IContactFeedRepository contactFeedRepository, ILoginProvider loginProvider, ILoggerFactory loggerFactory)
 {
     _contactFeedRepository = contactFeedRepository;
     _loginProvider = loginProvider;
     _logger = loggerFactory.CreateLogger(GetType());
     _logger.Info("ContactSummariesHub.ctor()");
 }
예제 #11
0
        /// <summary>
        /// Stores data like assets and item templates. Defaults to an in-memory cache, but can be implemented as writing to disk by the platform
        /// </summary>
        // public IDataCache DataCache { get; set; } = new MemoryDataCache();
        // public Templates Templates { get; private set; }

        internal Session(ILoginProvider loginProvider, AccessToken accessToken, GeoCoordinate geoCoordinate, DeviceWrapper deviceWrapper, GetPlayerMessage.Types.PlayerLocale playerLocale)
        {
            if (!ValidLoginProviders.Contains(loginProvider.ProviderId))
            {
                throw new ArgumentException("LoginProvider ID must be one of the following: " + string.Join(", ", ValidLoginProviders));
            }
            Logger = new Logger();

            State = SessionState.Stopped;

            Device = deviceWrapper;

            var handler = new HttpClientHandler
            {
                AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate,
                UseProxy = Device.Proxy != null,
                Proxy    = Device.Proxy
            };

            HttpClient = new HttpClient(handler);

            HttpClient.DefaultRequestHeaders.UserAgent.TryParseAdd(Constants.ApiUserAgent);
            HttpClient.DefaultRequestHeaders.ExpectContinue = false;

            AccessToken   = accessToken;
            LoginProvider = loginProvider;
            Player        = new Player(this, geoCoordinate, playerLocale);
            Map           = new Map(this);
            Templates     = new Templates(this);
            RpcClient     = new RpcClient(this);
            _heartbeat    = new HeartbeatDispatcher(this);
        }
예제 #12
0
        private async Task ClearUserTokenAndCookie(ILoginProvider loginProvider)
        {
            _loggingService.Trace("Executing AuthentificationService.ClearUserTokenAndCookie");

            await loginProvider.RemoveTokenFromSecureStore();

            loginProvider.ClearCookie();
        }
예제 #13
0
        private void AsyncLoginCompletedCallback(ILoginProvider provider, LoginInfo loginInfo)
        {
            provider.Completed -= AsyncLoginCompletedCallback;
            bool success = false;

            switch (loginInfo.Status)
            {
            case LoginStatus.None:
                break;

            case LoginStatus.ExceedMaxRetryCount:
                var loginId  = loginInfo.Parameter.LoginId;
                var password = loginInfo.Parameter.Password;
                var ip       = loginInfo.Parameter.Request.ClientInfo.RemoteIp;
                _Logger.WarnFormat("{0} login failed: exceed max login retry times", loginId);
                AuditHelper.AddIllegalLogin(AppType.TradingConsole, loginId, password, ip);
                Application.Default.TradingConsoleServer.SaveLoginFail(loginId, password, ip);
                break;

            case LoginStatus.LoginIdIsEmpty:
                _Logger.Warn("LoginId is empty");
                break;

            case LoginStatus.ParticipantServiceLoginFailed:
                break;

            case LoginStatus.UserIdIsEmpty:
                _Logger.WarnFormat("{0} is not a valid user", loginInfo.Parameter.LoginId);
                break;

            case LoginStatus.CheckPermissionFailed:
                break;

            case LoginStatus.NotAuthrized:
                _Logger.WarnFormat("{0} doesn't have the right to login trader", loginInfo.Parameter.LoginId);
                break;

            case LoginStatus.StateServerLoginFailed:
                break;

            case LoginStatus.StateServerNotLogined:
                break;

            case LoginStatus.Success:
                success = true;
                break;
            }
            if (!success)
            {
                LoginRetryTimeHelper.IncreaseFailedCount(loginInfo.Parameter.LoginId, ParticipantType.Customer, SettingManager.Default.ConnectionString);
                OnError(loginInfo.Parameter.Request, loginInfo.Parameter.AppType);
            }
            else
            {
                LoginRetryTimeHelper.ClearFailedCount(loginInfo.UserID, ParticipantType.Customer, SettingManager.Default.ConnectionString);
                ProcessPostAsyncLoginSuccess(loginInfo);
            }
        }
 public ContactGalleryAlbumsHub(IContactRepository contactRepository, IEnumerable<IGalleryProvider> galleryProviders, ILoginProvider sessionProvider, ILoggerFactory loggerFactory)
 {
     Debug.Print("ContactGalleryAlbumsHub.ctor()");
     _contactRepository = contactRepository;
     _galleryProviders = galleryProviders.ToArray();
     _sessionProvider = sessionProvider;
     _logger = loggerFactory.CreateLogger(GetType());
     _logger.Trace("ContactGalleryAlbumsHub.ctor(galleryProviders:{0})", string.Join(",", _galleryProviders.Select(cp => cp.GetType().Name)));
 }
예제 #15
0
파일: Login.cs 프로젝트: msx752/CoreBot
        /// <summary>
        /// Login with a stored <see cref="AccessToken" />.
        /// </summary>
        /// <param name="loginProvider"></param>
        /// <param name="accessToken"></param>
        /// <param name="initialLatitude">The initial latitude you will spawn at after logging into PokémonGo.</param>
        /// <param name="initialLongitude">The initial longitude you will spawn at after logging into PokémonGo.</param>
        /// <param name="deviceInfo">The <see cref="DeviceInfo"/> used by the <see cref="Session"/>, keep null if you want a randomly generated <see cref="DeviceInfo"/>.</param>
        /// <returns></returns>
        public static Session GetSession(ILoginProvider loginProvider, AccessToken accessToken, double initialLatitude, double initialLongitude, DeviceInfo deviceInfo = null)
        {
            if (accessToken.IsExpired)
            {
                throw new Exception("AccessToken is expired.");
            }

            return(new Session(loginProvider, accessToken, new GeoCoordinate(initialLatitude, initialLongitude), deviceInfo));
        }
 public ContactCalendarEventsHub(IContactRepository contactRepository, IEnumerable<ICalendarProvider> calendarProviders, ILoginProvider sessionProvider, ILoggerFactory loggerFactory)
 {
     Debug.Print("ContactCalendarEventsHub.ctor()");
     _contactRepository = contactRepository;
     _calendarProviders = calendarProviders.ToArray();
     _sessionProvider = sessionProvider;
     _logger = loggerFactory.CreateLogger(GetType());
     _logger.Trace("ContactCalendarEventsHub.ctor(calendarProviders:{0})", string.Join(",", _calendarProviders.Select(cp=>cp.GetType().Name)));
 }
예제 #17
0
        /// <summary>
        /// Login with a stored <see cref="AccessToken" />.
        /// </summary>
        /// <param name="loginProvider">The OAuth provider you use to authenticate.</param>
        /// <param name="accessToken">The <see cref="AccessToken"/> you want to re-use.</param>
        /// <param name="coordinate">The initial coordinate you will spawn at after logging into PokémonGo.</param>
        /// <param name="deviceWrapper">The <see cref="DeviceWrapper"/> used by the <see cref="Session"/>, keep null if you want a randomly generated <see cref="DeviceWrapper"/>.</param>
        /// <returns></returns>
        public static Session GetSession(ILoginProvider loginProvider, AccessToken accessToken, GeoCoordinate coordinate, DeviceWrapper deviceWrapper = null)
        {
            if (accessToken.IsExpired)
            {
                throw new ArgumentException($"{nameof(accessToken)} is expired.");
            }

            Logger.Debug("Authenticated from cache.");
            return(new Session(loginProvider, accessToken, coordinate, deviceWrapper));
        }
예제 #18
0
 public AuthorizationProvider(
     IRavenDatabaseProvider ravenDatabaseProvider,
     IRefreshTokenProvider refreshTokenProvider, ILoginProvider loginProvider, IUserProvider userProvider
     )
 {
     RavenDatabaseProvider = ravenDatabaseProvider;
     RefreshTokenProvider  = refreshTokenProvider;
     LoginProvider         = loginProvider;
     UserProvider          = userProvider;
 }
예제 #19
0
        protected override void OnInitialized()
        {
            InitializeComponent();
#if (TEST)
            return;
#else
            LoginProvider = new LoginProvider();
            NavigationService.NavigateAsync("NavigationPage/MainPage");
#endif
        }
        public AccountModule(ILoginProvider loginLinksProvider, ILandingProvider landingProvider, IUserService userService)
        {
            _loginProvider = loginLinksProvider;
            _landingProvider = landingProvider;
            _userService = userService;

            Get["/Login"] = Login;
            Get["/LoggedIn"] = LoggedIn;
            Get["/Logout"] = LogOut;
            Get["/Profile"] = Profile;
        }
예제 #21
0
        public HomePageViewModel()
        {
            var loginProvider  = DependencyService.Get <ILoginProvider>();
            var tokenStorage   = DependencyService.Get <ITokenStorage>();
            var messageService = DependencyService.Get <IMessageService>();

            _loginProvider  = loginProvider;
            _tokenStorage   = tokenStorage;
            _messageService = messageService;
            LoginCommand    = new Command(async() => await ExecuteLogin(), IsLoginEnabled);
        }
예제 #22
0
        /// <summary>
        /// Login with a stored <see cref="AccessToken" />.
        /// </summary>
        /// <param name="loginProvider"></param>
        /// <param name="accessToken"></param>
        /// <param name="initialLatitude">The initial latitude you will spawn at after logging into PokémonGo.</param>
        /// <param name="initialLongitude">The initial longitude you will spawn at after logging into PokémonGo.</param>
        /// <param name="deviceWrapper">The <see cref="DeviceWrapper"/> used by the <see cref="Session"/>, keep null if you want a randomly generated <see cref="DeviceWrapper"/>.</param>
        /// <returns></returns>
        public static Session GetSession(ILoginProvider loginProvider, AccessToken accessToken, double initialLatitude, double initialLongitude, DeviceWrapper deviceWrapper = null)
        {
            if (accessToken.IsExpired)
            {
                throw new Exception("AccessToken is expired.");
            }

            Logger.Debug("Authenticated from cache.");

            return(new Session(loginProvider, accessToken, new GeoCoordinate(initialLatitude, initialLongitude), deviceWrapper));
        }
예제 #23
0
 public AdminController(ILoginProvider loginProvider, IImageProvider imageProvider,
                        IPostRepository postRepository, ICategoryRepository categoryRepository, ITagRepository tagRepository,
                        IViewModelFactory viewModelFactory)
 {
     this.loginProvider      = loginProvider;
     this.imageProvider      = imageProvider;
     this.postRepository     = postRepository;
     this.categoryRepository = categoryRepository;
     this.tagRepository      = tagRepository;
     this.viewModelFactory   = viewModelFactory;
 }
예제 #24
0
        public LoginController(IHostingEnvironment hostingEnvironment, ILoginProvider loginProvider,
                               ISettingsProvider settingsProvider)
        {
            if (settingsProvider == null)
            {
                throw new ArgumentNullException(nameof(settingsProvider));
            }

            _hostingEnvironment = hostingEnvironment ?? throw new ArgumentNullException(nameof(hostingEnvironment));
            _loginProvider      = loginProvider ?? throw new ArgumentNullException(nameof(loginProvider));
            _settings           = settingsProvider.GetSettings <LoginControllerSettings>("LoginPlugin");
        }
        public LoginController(ILoginProvider loginProvider, ISettingsProvider settingsProvider,
                               IClaimsProvider claimsProvider /*, IAuthenticationService authenticationService*/)
        {
            if (settingsProvider == null)
            {
                throw new ArgumentNullException(nameof(settingsProvider));
            }

            _loginProvider  = loginProvider ?? throw new ArgumentNullException(nameof(loginProvider));
            _claimsProvider = claimsProvider ?? throw new ArgumentNullException(nameof(claimsProvider));
            //_authenticationService = authenticationService ?? throw new ArgumentNullException(nameof(authenticationService));
            _settings = settingsProvider.GetSettings <LoginControllerSettings>(nameof(LoginPlugin));
        }
 public SettingsViewModel(IVersionTracking versionTracking, IPermissions permissions, IUserDialogs userDialogs,
                          IPreferences preferences, IMvxMessenger messenger, ISecureStorage secureStorage, ILoginProvider loginProvider,
                          IFirebaseService firebaseService)
 {
     _versionTracking = versionTracking;
     _permissions     = permissions;
     _userDialogs     = userDialogs;
     _preferences     = preferences;
     _messenger       = messenger;
     _secureStorage   = secureStorage;
     _loginProvider   = loginProvider;
     _firebaseService = firebaseService;
 }
예제 #27
0
        public AzureCloudService()
        {
            MobileService = new MobileServiceClient(Helpers.Locations.AppServiceUrl)
            {
                SerializerSettings = new MobileServiceJsonSerializerSettings {
                    CamelCasePropertyNames = true
                }
            };

            // Get the login provider for this service
            loginProvider = DependencyService.Get <ILoginProvider>();
            fileProvider  = DependencyService.Get <IFileProvider>();
        }
        public LoginMiddleware(RequestDelegate next, ILoginProvider loginProvider,
            ISettingsProvider settingsProvider, IAuthenticationService authenticationService,
            IClaimsProvider claimsProvider)
        {
            if (settingsProvider == null)
                throw new ArgumentNullException(nameof(settingsProvider));

            _next = next ?? throw new ArgumentNullException(nameof(next));
            _loginProvider = loginProvider ?? throw new ArgumentNullException(nameof(loginProvider));
            _authenticationService = authenticationService ?? throw new ArgumentNullException(nameof(authenticationService));
            _claimsProvider = claimsProvider ?? throw new ArgumentNullException(nameof(claimsProvider));
            _loginControllerSettings = settingsProvider.GetSettings<LoginControllerSettings>(nameof(LoginPlugin));
        }
예제 #29
0
        /// <summary>
        /// Login through OAuth with Google.
        /// </summary>
        /// <param name="loginProvider">The OAuth provider you use to authenticate.</param>
        /// <param name="initialLatitude">The initial latitude you will spawn at after logging into UniteGo.</param>
        /// <param name="initialLongitude">The initial longitude you will spawn at after logging into UniteGo.</param>
        /// <param name="deviceWrapper">The <see cref="DeviceWrapper"/> used by the <see cref="Session"/>, keep null if you want a randomly generated <see cref="DeviceWrapper"/>.</param>
        /// <param name = "playerLocale"></param>
        /// <returns></returns>
        public static async Task <Session> GetSession(ILoginProvider loginProvider, double initialLatitude, double initialLongitude, DeviceWrapper deviceWrapper = null, CreateOrUpdatePlayerMessage.Types.ClientPlayerLocale playerLocale = null)
        {
            DeviceWrapper device = deviceWrapper ?? DeviceInfoUtil.GetRandomDevice();

            CreateOrUpdatePlayerMessage.Types.ClientPlayerLocale locale = playerLocale ?? new CreateOrUpdatePlayerMessage.Types.ClientPlayerLocale {
                Country = "US", Language = "en", Timezone = "America/New_York"
            };
            string language = locale.Language + "-" + locale.Country;
            var    session  = new Session(loginProvider, await loginProvider.GetAccessToken(device.UserAgent, language), new GeoCoordinate(initialLatitude, initialLongitude), device, locale);

            session.Logger.Debug("Authenticated through Google.");
            return(session);
        }
예제 #30
0
        public PipeLineController(HttpContext context)
        {
            _context = context;
            var services = _context.RequestServices;

            //_config = services.GetRequiredService<IConfiguration>();
            //_userManager = services.GetRequiredService<IUserManager>();
            //_logger = services.GetRequiredService<ILogger>();
            _actionManager = services.GetRequiredService <IActionManager>();
            _loginProvider = services.GetRequiredService <ILoginProvider>();
            _routeValues   = _context
                             .AddItem <PipeLineRouteValues>(new PipeLineRouteValues(_context))
                             .GetItem <PipeLineRouteValues>();
        }
예제 #31
0
 private void AsyncLoginCompletedCallback(ILoginProvider provider,LoginInfo loginInfo)
 {
     provider.Completed -= AsyncLoginCompletedCallback;
     bool success = false;
     switch (loginInfo.Status)
     {
         case LoginStatus.None:
             break;
         case LoginStatus.ExceedMaxRetryCount:
             var loginId = loginInfo.Parameter.LoginId;
             var password = loginInfo.Parameter.Password;
             var ip = loginInfo.Parameter.Request.ClientInfo.RemoteIp;
             _Logger.WarnFormat("{0} login failed: exceed max login retry times", loginId);
             AuditHelper.AddIllegalLogin(AppType.TradingConsole, loginId, password, ip);
             Application.Default.TradingConsoleServer.SaveLoginFail(loginId, password, ip);
             break;
         case LoginStatus.LoginIdIsEmpty:
             _Logger.Warn("LoginId is empty");
             break;
         case LoginStatus.ParticipantServiceLoginFailed:
             break;
         case LoginStatus.UserIdIsEmpty:
             _Logger.WarnFormat("{0} is not a valid user", loginInfo.Parameter.LoginId);
             break;
         case LoginStatus.CheckPermissionFailed:
             break;
         case LoginStatus.NotAuthrized:
             _Logger.WarnFormat("{0} doesn't have the right to login trader", loginInfo.Parameter.LoginId);
             break;
         case LoginStatus.StateServerLoginFailed:
             break;
         case LoginStatus.StateServerNotLogined:
             break;
         case LoginStatus.Success:
             success = true;
             break;
     }
     if (!success)
     {
         LoginRetryTimeHelper.IncreaseFailedCount(loginInfo.Parameter.LoginId, ParticipantType.Customer, SettingManager.Default.ConnectionString);
         OnError(loginInfo.Parameter.Request, loginInfo.Parameter.AppType);
     }
     else
     {
         LoginRetryTimeHelper.ClearFailedCount(loginInfo.UserID, ParticipantType.Customer, SettingManager.Default.ConnectionString);
         ProcessPostAsyncLoginSuccess(loginInfo);
     }
 }
예제 #32
0
        /// <summary>
        /// Stores data like assets and item templates. Defaults to an in-memory cache, but can be implemented as writing to disk by the platform
        /// </summary>
        // public IDataCache DataCache { get; set; } = new MemoryDataCache();
        // public Templates Templates { get; private set; }

        internal Session(ILoginProvider loginProvider, AccessToken accessToken, GeoCoordinate geoCoordinate, Signature.Types.DeviceInfo deviceInfo = null)
        {
            if (!ValidLoginProviders.Contains(loginProvider.ProviderId))
            {
                throw new ArgumentException($"LoginProvider ID must be one of the following: {string.Join(", ", ValidLoginProviders)}");
            }

            HttpClient    = new PokemonHttpClient();
            DeviceInfo    = deviceInfo ?? DeviceInfoHelper.GetRandomIosDevice();
            AccessToken   = accessToken;
            LoginProvider = loginProvider;
            // Player = new Player(geoCoordinate);
            //Map = new Map(this);
            //RpcClient = new RpcClient(this);
            //_heartbeat = new HeartbeatDispatcher(this);
        }
예제 #33
0
        private void Login(string userName, string password, bool isManual)
        {
            GameModel      model         = ProfileManager.CurrentProfile.GameModel;
            ILoginProvider loginProvider = ConfigurationManager.GetConfiguration(model).CreateLoginProvider();

            loginProvider.LoginStateChanged += eventAccessor.OnLoginStateChanged;
            loginProvider.LoginCompleted    += eventAccessor.OnLoginCompleted;
            if (isManual)
            {
                loginProvider.TryManualLogin(userName, password);
            }
            else
            {
                loginProvider.TryLogin(userName, password);
            }
        }
예제 #34
0
 public AccountController(
     IConfiguration configuration,
     ILoginProvider loginProvider,
     ILoggedOutViewModelBuilder loggedOutViewModelBuilder,
     ILoginViewModelBuilder loginViewModelBuilder,
     ILogOutViewModelBuilder logOutViewModelBuilder,
     IIdentityServerInteractionService interaction,
     IClientStore clientStore)
 {
     _configuration             = configuration;
     _loginProvider             = loginProvider;
     _loggedOutViewModelBuilder = loggedOutViewModelBuilder;
     _loginViewModelBuilder     = loginViewModelBuilder;
     _logOutViewModelBuilder    = logOutViewModelBuilder;
     _interaction = interaction;
     _clientStore = clientStore;
 }
예제 #35
0
        public static void Init()
        {
            if (init)
            {
                return;
            }

            using (DatabaseContext db = new DatabaseContext())
            {
                userCategories    = db.UserCategories.ToList();
                userRoles         = db.UserRoles.AsNoTracking().ToList();
                branchsAffiliates = db.BranchsAffiliates.AsNoTracking().ToList();
                stickerTypes      = db.StickerTypes.Include(s => s.UserCategory).AsNoTracking().ToList();
                stickerTerms      = db.StickerTerms.AsNoTracking().Where(s => DateTime.Now >= s.StartDate && DateTime.Now <= s.EndDate).ToList();

                loginProvider = new DummyLDAPProvider();
            }
            init = true;
        }
예제 #36
0
        public IndexModule(ILoginProvider loginLinksProvider)
        {
            _loginLinksProvider = loginLinksProvider;

            Get["/"] = Index;
        }
예제 #37
0
 public LoginService(ILoginProvider loginProvider)
 {
     _loginProvider = loginProvider;
 }
예제 #38
0
 public ContactController(IContactRepository contactRepository, ILoginProvider loginProvider)
 {
     _contactRepository = contactRepository;
     _loginProvider = loginProvider;
 }
예제 #39
0
 public MembershipController(IQueryDispatcher queryDispatcher, ILoginProvider loginProvider, ICommandDispatcher commandDispatcher)
 {
     this._queryDispatcher = queryDispatcher;
     this._loginProvider = loginProvider;
     this._commandDispatcher = commandDispatcher;
 }
예제 #40
0
 public AccountController(IAuthenticationProviderGateway authenticationProviderGateway,
                          ILoginProvider loginProvider)
 {
     _authenticationProviderGateway = authenticationProviderGateway;
     _loginProvider = loginProvider;
 }
예제 #41
0
 public LoginManager()
 {
     _LoginProvider = new LoginProvider();
     _LoginProvider.Completed += AsyncLoginCompletedCallback;
 }
예제 #42
0
 public LoginController(ILoginProvider loginProvider)
 {
     this._loginProvider = loginProvider;
 }
 public CustomMembershipProvider()
 {
     _LoginProvider = DependencyResolver.Current.GetService<ILoginProvider>();
     _UserRepository = DependencyResolver.Current.GetService<IUserRepository>();
 }
예제 #44
0
 public AccountController(ILoginProvider loginProvider)
 {
     Log.Debug("Entering AccountController()");
     _loginProvider = loginProvider;
 }
예제 #45
0
 public ContactProfileHub(IContactRepository contactsFeedProviders, ILoginProvider loginProvider, ILoggerFactory loggerFactory)
 {
     _contactRepository = contactsFeedProviders;
     _loginProvider = loginProvider;
     _logger = loggerFactory.CreateLogger(GetType());
 }