예제 #1
0
 public SteamWebAccess(WebSession session, IPAddress ipAddress, IWebProxy proxy) : this(session)
 {
     _ipAddress = ipAddress;
     _proxy     = proxy;
 }
예제 #2
0
 public SteamWebAccess(WebSession session, IWebProxy proxy) : this(session)
 {
     _proxy = proxy;
 }
예제 #3
0
 public SteamWebAccess(WebSession session)
 {
     _session   = session;
     _ipAddress = IPAddress.Any;
     _proxy     = null;
 }
예제 #4
0
 public SteamWebAccess(WebSession session, IPAddress ipAddress) : this(session)
 {
     _ipAddress = ipAddress;
 }
예제 #5
0
        protected virtual Task <bool> ProcessLoginResponse(string response)
        {
            var loginResponse = JsonConvert.DeserializeObject <LoginResponse>(response);

            if (loginResponse == null)
            {
                throw new UserLoginException(UserLoginErrorCode.GeneralFailure, this);
            }

            if (loginResponse.Message?.ToLower().Contains("incorrect login") == true ||
                loginResponse.Message?.ToLower().Contains("password") == true &&
                loginResponse.Message?.ToLower().Contains("incorrect") == true)
            {
                throw new UserLoginException(UserLoginErrorCode.BadCredentials, this);
            }

            if (loginResponse.CaptchaNeeded)
            {
                RequiresCaptchaCode = true;
                CaptchaGID          = loginResponse.CaptchaGID;
                CachedCaptchaImage  = null;

                throw new UserLoginException(UserLoginErrorCode.NeedsCaptchaCode, this);
            }

            if (!string.IsNullOrWhiteSpace(loginResponse.CaptchaGID) &&
                loginResponse.CaptchaGID != "-1" &&
                CaptchaGID != loginResponse.CaptchaGID)
            {
                CaptchaGID         = loginResponse.CaptchaGID;
                CachedCaptchaImage = null;
            }

            if (loginResponse.EmailAuthNeeded)
            {
                RequiresEmailVerification = true;
                SteamId     = loginResponse.EmailSteamId > 0 ? loginResponse.EmailSteamId : SteamId;
                EmailDomain = loginResponse.EmailDomain;

                throw new UserLoginException(UserLoginErrorCode.NeedsEmailVerificationCode, this);
            }

            if (loginResponse.TwoFactorNeeded && !loginResponse.Success)
            {
                RequiresTwoFactorAuthenticationCode = true;
                SteamId = loginResponse.EmailSteamId > 0 ? loginResponse.EmailSteamId : SteamId;

                throw new UserLoginException(UserLoginErrorCode.NeedsTwoFactorAuthenticationCode, this);
            }

            if (loginResponse.EmailSteamId > 0 && SteamId != loginResponse.EmailSteamId)
            {
                SteamId = loginResponse.EmailSteamId;
            }

            if (loginResponse.Message?.Contains("too many login failures") == true)
            {
                throw new UserLoginException(UserLoginErrorCode.TooManyFailedLoginAttempts, this);
            }

            if (!loginResponse.LoginComplete)
            {
                return(Task.FromResult(false));
            }

            if (loginResponse.TransferParameters != null && !string.IsNullOrWhiteSpace(SteamWebAccess?.Session?.SessionId))
            {
                var newSession = new WebSession(loginResponse.TransferParameters, SteamWebAccess.Session.SessionId);

                if (newSession.HasEnoughInfo())
                {
                    SteamWebAccess = new SteamWebAccess(newSession);
                }
            }

            return(Task.FromResult(true));
        }