/// <summary>
 /// Servers the operation manager did fail server login.
 /// </summary>
 /// <param name="serverOperationManager">
 /// The server operation manager.
 /// </param>
 /// <param name="error">
 /// The error.
 /// </param>
 /// <param name="passwordChanged">
 /// The password changed.
 /// </param>
 public void ServerOperationManagerDidFailServerLogin(
     ServerOperationManager serverOperationManager,
     Exception error,
     PasswordChangeResult passwordChanged)
 {
     this.IsLoggedIn = false;
     this.Delegate?.ServerOperationManagerDidFailServerLogin(serverOperationManager, error, passwordChanged);
 }
 /// <summary>
 /// Servers the operation manager did fail with internet connection error.
 /// </summary>
 /// <param name="serverOperationManager">
 /// The server operation manager.
 /// </param>
 /// <param name="error">
 /// The error.
 /// </param>
 /// <param name="passwordChangeResult">
 /// The password change result.
 /// </param>
 public void ServerOperationManagerDidFailWithInternetConnectionError(
     ServerOperationManager serverOperationManager,
     Exception error,
     PasswordChangeResult passwordChangeResult)
 {
     this.IsLoggedIn = false;
     this.Delegate?.ServerOperationManagerDidFailWithInternetConnectionError(
         serverOperationManager,
         error,
         passwordChangeResult);
 }
Exemple #3
0
        public ActionResult ChangePassword(ChangePassword model)
        {
            PasswordChangeResult result = m_SystemUserService.ChangePassword(new ChangePasswordRequest(currentStaff.Person.OfficialEmail, true, model.NewPassword, model.OldPassword));

            if (result.Errors.Count > 0)
            {
                ViewBag.StatusMsg = result.Errors[0];
                return(View());
            }

            return(_ViewProfile());
        }
 /// <summary>
 /// Maneja el resultado de intentar cambiar la contraseña de la cuenta de un jugador
 /// </summary>
 /// <param name="passwordChangeResult"></param>
 public void GetPasswordChangeResult(PasswordChangeResult passwordChangeResult)
 {
     if (passwordChangeResult == PasswordChangeResult.ChangedPassword)
     {
         DialogWindowManager.ShowSuccessWindow(Resources.SuccessfulPasswordChangeMessage);
         LogIn login = App.Current.Windows.OfType <LogIn>().FirstOrDefault();
         login.EnableNavigation();
         login.NavigationService.Navigate(new LogInPage());
     }
     else
     {
         DialogWindowManager.ShowErrorWindow(Resources.PasswordChangeErrorMessage);
     }
 }
 /// <summary>
 /// Servers the operation manager requires language for session.
 /// </summary>
 /// <param name="serverOperationManager">
 /// The server operation manager.
 /// </param>
 /// <param name="availableLanguages">
 /// The available languages.
 /// </param>
 /// <param name="sessionAttributes">
 /// The session attributes.
 /// </param>
 /// <param name="serverInfo">
 /// The server information.
 /// </param>
 /// <param name="passwordChanged">
 /// The password changed.
 /// </param>
 public void ServerOperationManagerRequiresLanguageForSession(
     ServerOperationManager serverOperationManager,
     List <ServerLanguage> availableLanguages,
     Dictionary <string, object> sessionAttributes,
     List <object> serverInfo,
     PasswordChangeResult passwordChanged)
 {
     this.Delegate?.ServerOperationManagerRequiresLanguageForSession(
         serverOperationManager,
         availableLanguages,
         sessionAttributes,
         serverInfo,
         passwordChanged);
 }
        /// <summary>
        /// Servers the operation manager did perform server login.
        /// </summary>
        /// <param name="serverOperationManager">
        /// The server operation manager.
        /// </param>
        /// <param name="availableLanguages">
        /// The available languages.
        /// </param>
        /// <param name="sessionAttributes">
        /// The session attributes.
        /// </param>
        /// <param name="serverInfo">
        /// The server information.
        /// </param>
        /// <param name="passwordChanged">
        /// The password changed.
        /// </param>
        public void ServerOperationManagerDidPerformServerLogin(
            ServerOperationManager serverOperationManager,
            List <ServerLanguage> availableLanguages,
            Dictionary <string, object> sessionAttributes,
            List <object> serverInfo,
            PasswordChangeResult passwordChanged)
        {
            this.IsLoggedIn = true;

            this.Delegate?.ServerOperationManagerDidPerformServerLogin(
                serverOperationManager,
                availableLanguages,
                sessionAttributes,
                serverInfo,
                passwordChanged);
        }
        public void PasswordChangeResult_ReturnErrorChanging_PasswordChangeResult()
        {
            try
            {
                var baseAddress = new Uri("net.tcp://*****:*****@gmail.com",
                    PinConfirmacion       = "1234",
                    PreguntaRecuperacion  = "testquestion?",
                    RespuestaConfirmacion = "testanswer",
                };

                playerClient.ChangePassword(testPlayer.Apodo, "newpassword");
                PlayerCallbackHandler playerHandler = new PlayerCallbackHandler();
                PasswordChangeResult  result        = playerHandler.passwordChangeResult;

                Assert.AreEqual(result, PasswordChangeResult.ErrorChanging);
            }
            catch (EndpointNotFoundException)
            {
                playerClient.Abort();
            }
            catch (CommunicationException)
            {
                playerClient.Abort();
            }
        }
        /// <summary>
        /// Implementación de Contrato para actualizar la contraseña de un jugador
        /// </summary>
        /// <param name="userNickname"></param>
        /// <param name="password"></param>
        public void ChangePassword(string userNickname, string password)
        {
            PasswordChangeResult changeResult = PasswordChangeResult.ErrorChanging;

            if (jugadorDataManager.CheckNickname(userNickname))
            {
                string newPassword  = hashText.TextToHash(password);
                int    resultChange = jugadorDataManager.ChangePassword(userNickname, newPassword);

                if (resultChange > 0)
                {
                    changeResult = PasswordChangeResult.ChangedPassword;
                }
            }

            PlayerCallback.GetPasswordChangeResult(changeResult);
        }
Exemple #9
0
        static void ChangePassword(string incomingphonenumber, string incomingtext)
        {
            string mailbody = $"Received request from: {incomingphonenumber}<br>SMS Text: {incomingtext}<br>Result: ";

            _logger.Info("Received SMS");
            _logger.Info($"Phone number: {incomingphonenumber}");
            _logger.Info($"Incoming text: {incomingtext}");

            //Check if this is a valid phone number. This check let us ignore messages from short/text numbers
            PhoneNumber phoneNumber = null;

            try
            {
                phoneNumber = _phoneNumberUtil.Parse(incomingphonenumber, _currentPhoneRegion);
            }
            catch (Exception ex)
            {
                _logger.Error($"Exception during phone number parsing:  {ex.Message} ({ex.GetType()})");
            }

            if (phoneNumber == null || !_phoneNumberUtil.IsValidNumber(phoneNumber) || incomingtext.Count(f => f == ' ') > 2)
            {
                _logger.Warn("Ignoring SMS, Reason: Invalid phone number");
                SendMail("SMS Self Service - Invalid SMS received", mailbody + "Invalid (Operator/Advertisement) SMS, ignoring...");
                return;
            }

            if (_config.GetValue("Protection/Bruteforce/Enabled", true) && _intrusionsList.ContainsKey(incomingphonenumber) && _intrusionsList[incomingphonenumber] > _config.GetValue("Protection/Bruteforce/MaximumRetries", 5))
            {
                _logger.Warn("Ignoring SMS, Reason: possible account name bruteforcing.");
                return;
            }

            //Generate new password
            string newpass = Regex.Replace(Membership.GeneratePassword(8, 0), @"[^a-zA-Z0-9]", m => "9");

            try
            {
                //Get the username from various formats
                string login = incomingtext.Replace("/", "\\").ToLower();
                if (login.Contains("@")) // [email protected]
                {
                    login = login.Split('@')[0];
                }
                if (login.Contains("\\")) // domain.com\username
                {
                    login = login.Split('\\')[1];
                }
                login = login.Trim();

                PasswordChangeResult result = _activeDirectory.ChangeUserPassword(login, newpass, phoneNumber.NationalNumber.ToString());
                string message;
                if (result == PasswordChangeResult.Success)
                {
                    _logger.Info($"Successfully changed password for {login}");

                    message = _config.GetValue("Messages/Success", "Your temporary password:"******" " + newpass;
                    }

                    mailbody += "Successfully changed password";
                }
                else if (result == PasswordChangeResult.UserNotFound)
                {
                    _logger.Error($"User \"{login}\" not found");

                    message = _config.GetValue("Messages/UserNotFound", "Incorrect username");

                    mailbody += "User not found";
                }
                else if (result == PasswordChangeResult.DisabledAccount)
                {
                    _logger.Error("Account is disabled: " + login);

                    message = _config.GetValue("Messages/AccountDisabled",
                                               "Account for this user is currently disabled");

                    mailbody += "Account is disabled";
                }
                else if (result == PasswordChangeResult.NoFingerprintAttached)
                {
                    _logger.Error($"No phone number attached to account: {login}");

                    message = _config.GetValue("Messages/NoPhoneAttached",
                                               "This service cannot be used by this user");

                    mailbody += "No phone number attached";
                }
                else if (result == PasswordChangeResult.InvalidFingerprint)
                {
                    _logger.Warn($"INTRUSION? PHONE NUMBER DIFFERS FROM ONE ASSOCIATED WITH THIS ACCOUNT! Incoming number: {incomingphonenumber}, incoming text: {incomingtext}");

                    message = _config.GetValue("Messages/IncorrectNumber", "");

                    mailbody += "<font color=\"red\">This phone number is not the one associated with this account.</font>";

                    if (!_intrusionsList.ContainsKey(incomingphonenumber))
                    {
                        _intrusionsList[incomingphonenumber] = 0;
                    }
                    _intrusionsList[incomingphonenumber] += 1;
                }
                else
                {
                    _logger.Fatal($"Error while when fulfilling password change request: {result}");

                    message = _config.GetValue("Messages/InternalError", "Service temporary not available");

                    mailbody += $"<font color=\"red\">ERROR WHILE FULFILLING REQUEST: {result}</font>";
                }

                if (!string.IsNullOrEmpty(message))
                {
                    Utils.SendMessage(_comm, incomingphonenumber, message);
                }

                SendMail("SMS Self Service - Password Change Request", mailbody);
            }
            catch (Exception ex)
            {
                _logger.Fatal($"Error while changing user password: {ex.Message} ({ex.GetType()}) | {ex}");
            }
        }
Exemple #10
0
        private async void CheckInsta_DoWork(object sender, DoWorkEventArgs e)
        {
            _threadCount++;
            List <Dictionary <string, object> > proxyOptions = new List <Dictionary <string, object> >();

            int  checkPos          = 0;
            bool threadIsWorking   = true;
            int  tryToFindCookies0 = 0;

            while ((!_account.AllPathChecked) && _account.CountUsers > 500)
            {
                int proxyPos = 0;
                for (int j = 0; j < 25; j++)
                {
                    try
                    {
                        //if (_deleteProxy.Contains(_proxy.InstaProxies[0]))
                        //{
                        //    lock (_proxy.locker)
                        //    {
                        //        _proxy.InstaProxies.Remove(_proxy.InstaProxies[0]);
                        //        j--;
                        //        continue;
                        //    }
                        //}
                        lock (_proxy.locker)
                        {
                            proxyOptions.Add(_proxy.InstaProxies[0]);
                            _proxy.InstaProxies.Remove(_proxy.InstaProxies[0]);
                        }
                    }
                    catch
                    {
                        if (_noMoreProxy == true)
                        {
                            _noMoreProxy = false;
                            lock (LogIO.locker) logging.Invoke(LogIO.mainLog, new Log()
                                {
                                    Date = DateTime.Now, LogMessage = "Last 500 proxy!", UserName = null, Method = "Model.CheckInsta"
                                });
                            UpdateProxy();
                            while (!_proxy.IsProxyReady)
                            {
                            }
                            _noMoreProxy = true;
                        }
                    }
                }

                int    i_position = -1;
                string instaLogin = null, instaPassword = null;
                for (int i = 0; i < 225; i++)
                {
                    if (proxyOptions.Count == 0)
                    {
                        break;
                    }

                    Dictionary <string, object> valueProxy = proxyOptions[Randomer.Next(0, proxyOptions.Count)];

                    lock (_account.locker)
                        if (_account.CountUsers <= 150 && !_account.AllPathChecked)
                        {
                            _account.SetUser();
                        }
                    if (i_position != i)
                    {
                        try
                        {
                            i_position        = i;
                            tryToFindCookies0 = 0;
                            Dictionary <string, string> tempAcc;
                            lock (_account.locker)
                            {
                                tempAcc = _account.Users[Randomer.Next(0, _account.CountUsers)];
                            }
                            instaLogin    = tempAcc["instaLogin"];
                            instaPassword = tempAcc["instaPassword"];
                            while (_account.UsersForDeleting.Contains(instaLogin + ":" + instaPassword))
                            {
                                lock (_account.locker)
                                {
                                    tempAcc = _account.Users[Randomer.Next(0, _account.CountUsers)];
                                }
                                instaLogin    = tempAcc["instaLogin"];
                                instaPassword = tempAcc["instaPassword"];
                            }
                        }
                        catch
                        {
                            threadIsWorking = false;
                            break;
                        }
                    }

                    bool        check = true;
                    HttpAndroid android;
                    try
                    {
                        string agent;
                        lock (_agents.locker) agent = _agents.Agents[Randomer.Next(0, _agents.CountAgents)];

                        android = new HttpAndroid(instaLogin, instaPassword, valueProxy, agent);
                        var loggedIn = await android.LogIn();

                        if (loggedIn == null)
                        {
                            if (tryToFindCookies0 == 1)
                            {
                                proxyPos++;
                                checkPos = 0;
                                lock (locker) ProxySwitched++;
                            }
                            else if (tryToFindCookies0 == 2)
                            {
                                i++;
                                lock (_account.locker) { _account.UsersForDeleting.Add(instaLogin + ":" + instaPassword); }
                                lock (locker) AccsSwitched++;
                                tryToFindCookies0 = -1;
                                lock (locker) AccsBlocked++;
                            }
                            i--;
                            tryToFindCookies0++;
                            continue;
                        }

                        if (loggedIn.status == "success")
                        {
                            ProfileResult profile = await android.GetProfile();

                            if (profile != null) //means that account is logined
                            {
                                int randomPosition = Randomer.Next(0, _accMails.CountMails);
                                var resMail        = _accMails.Mails[randomPosition];
                                _accMails.Mails.Remove(_accMails.Mails[randomPosition]);
                                _accMails.MailsForDeleting.Add(resMail["mailLogin"] + ":" + resMail["mailPassword"]);

                                string writePassword = instaPassword;

                                DateTime time = DateTime.Now;
                                Thread.Sleep(3000);
                                UpdateProfileResult updateStatus = await android.UpdateProfile(profile, resMail["mailLogin"]);

                                if (updateStatus.status == "ok")
                                {
                                    bool   confirmed = true;
                                    string path      = null;
                                    try
                                    {
                                        Mail mailClient = new Mail(resMail["mailLogin"], resMail["mailPassword"]);
                                        Thread.Sleep(1000);
                                        path = mailClient.GetMailPath(time);
                                        Thread.Sleep(1000);
                                        if (_proxy.MailProxies.Count > 0)
                                        {
                                            confirmed = android.ConfirmMail(path, _proxy.MailProxies[Randomer.Next(0, _proxy.MailProxies.Count)]);
                                        }
                                        else
                                        {
                                            confirmed = android.ConfirmMail(path, valueProxy);
                                        }
                                    }
                                    catch
                                    {
                                        lock (LogIO.locker) logging.Invoke(LogIO.mainLog, new Log()
                                            {
                                                Date = DateTime.Now, LogMessage = $"Email not confirmed: {resMail["mailLogin"]}:{resMail["mailPassword"]}", Method = "Model.CheckInsta", UserName = null
                                            });
                                        confirmed = false;
                                    }


                                    string newPass = Generator.GeneratePassword();
                                    PasswordChangeResult passResult = await android.ChangePassword(newPass);

                                    if (passResult.status == "ok")
                                    {
                                        writePassword = newPass;
                                    }
                                    else
                                    {
                                        lock (_fileWorker.locker) _fileWorker.BadPass($"{profile.form_data.username}:{instaPassword}");
                                    }


                                    if (confirmed)
                                    {
                                        string goodValidResult = profile.form_data.username + ":" + writePassword + ":" + resMail["mailLogin"] + ":" + resMail["mailPassword"];
                                        AccountInfoDataSet_Success.Add(goodValidResult);
                                        lock (LogIO.locker) logging.Invoke(LogIO.easyPath, new Log()
                                            {
                                                UserName = $"{profile.form_data.username}:{writePassword}", Date = DateTime.Now, LogMessage = "Good Valid", Method = "Model.CheckInsta"
                                            });
                                        lock (_fileWorker.locker) _fileWorker.GoodValid(goodValidResult);
                                    }
                                    else
                                    {
                                        string mailNotConfirmedResult = profile.form_data.username + ":" + writePassword + ":" + resMail["mailLogin"] + ":" + resMail["mailPassword"];
                                        AccountInfoDataSet_Success.Add(mailNotConfirmedResult);
                                        lock (LogIO.locker) logging.Invoke(LogIO.easyPath, new Log()
                                            {
                                                UserName = $"{profile.form_data.username}:{writePassword}", Date = DateTime.Now, LogMessage = $"Mail have troubles. Account not confirmed, but mail changed", Method = "Model.CheckInsta"
                                            });
                                        lock (_fileWorker.locker) _fileWorker.BadMail(mailNotConfirmedResult);
                                    }
                                }
                                else
                                {
                                    string account      = instaLogin + ":" + writePassword;
                                    var    checkProfile = await android.GetProfile();

                                    if (profile.form_data.email == checkProfile.form_data.email && !String.IsNullOrEmpty(checkProfile.form_data.phone_number))
                                    {
                                        account += ":" + resMail["mailLogin"] + ":" + resMail["mailPassword"];
                                        lock (_fileWorker.locker) _fileWorker.BadValid(account);
                                    }
                                    else if (profile.form_data.email == checkProfile.form_data.email)
                                    {
                                        lock (_fileWorker.locker) _fileWorker.BadMail(account);
                                    }
                                }
                            }
                        }
                        else if (loggedIn.status == "checkpoint_required")//means that account is required
                        {
                            string account = $"{instaLogin}:{instaPassword}";
                            lock (LogIO.locker) logging.Invoke(LogIO.easyPath, new Log()
                                {
                                    UserName = null, Date = DateTime.Now, LogMessage = $"Challenge required! {account}", Method = "Model.CheckInsta"
                                });

                            lock (locker)
                            {
                                AccountInfoDataSet_Required.Add(account);
                            }
                            lock (_fileWorker.locker)
                            {
                                _fileWorker.Checkpoint(account);
                            }
                        }
                        else if (loggedIn.status == "Request Timeout")
                        {
                            i--;
                            check = false;
                        }
                        //else
                        //{
                        //    lock (LogIO.locker) logging.Invoke(LogIO.mainLog, new Log() { UserName = null, Date = DateTime.Now, LogMessage = $"Bad Credentials", Method = "Model.CheckInsta" });
                        //}
                    }
                    catch (Exception ex)
                    {
                        if (ex.Message == "Невозможно соединиться с удаленным сервером" || ex.Message == "Unable to connect to the remote server")
                        {
                            Debug.WriteLine("Remote Server");
                            lock (LogIO.locker) logging.Invoke(LogIO.mainLog, new Log()
                                {
                                    UserName = null, Date = DateTime.Now, LogMessage = $"Unable to connect to remote server! Switch proxy", Method = "Model.CheckInsta"
                                });
                            lock (locker) ProxyBlocked++;
                            //lock (locker) _deleteProxy.Add(valueProxy);
                            lock (locker) ProxySwitched++;
                            proxyOptions.Remove(valueProxy);
                            checkPos = 0;
                            proxyPos++;
                        }
                        else if (ex.Message.Contains("400") || ex.Message.Contains("403"))
                        {
                            lock (LogIO.locker) logging.Invoke(LogIO.mainLog, new Log()
                                {
                                    UserName = null, Date = DateTime.Now, LogMessage = $"Exception 400! Bad request! Switch proxy", Method = "Model.CheckInsta"
                                });
                            lock (locker) ProxyBlocked++;
                            //lock (locker) _deleteProxy.Add(valueProxy);
                            lock (locker) ProxySwitched++;
                            proxyOptions.Remove(valueProxy);
                            checkPos = 0;
                            proxyPos++;
                        }
                        else
                        {
                            lock (LogIO.locker) logging.Invoke(LogIO.mainLog, new Log()
                                {
                                    UserName = null, Date = DateTime.Now, LogMessage = $"Exception! {ex.Message} -- {ex.Source}", Method = "Model.CheckInsta"
                                });
                            checkPos++;
                        }

                        i--;
                        check = false;
                    }
                    if (check)
                    {
                        lock (_account.locker) { _account.UsersForDeleting.Add(instaLogin + ":" + instaPassword); }
                        lock (locker) AccsSwitched++;
                    }

                    checkPos++;
                    if (checkPos % 10 == 0)
                    {
                        lock (locker) ProxySwitched++;
                        proxyPos++;
                    }
                }
                proxyOptions.Clear();

                if (!threadIsWorking)
                {
                    break;
                }
            }
            _threadCount--;
        }
 public void GetPasswordChangeResult(PasswordChangeResult passwordChangeResult)
 {
     this.passwordChangeResult = passwordChangeResult;
 }
        public virtual PasswordChangeResult ChangePassword(ChangePasswordRequest request)
        {
            if (request == null) throw new ArgumentNullException("request");
            var result = new PasswordChangeResult();

            if(string.IsNullOrWhiteSpace(request.Email))
                result.AddError(_localizationService.GetResource("Account.ChangePassword.Errors.EmailIsNotProvided", false));
            if (request.ValidateRequest)
            {
                if (string.IsNullOrEmpty(request.OldPassword))
                    result.AddError(_localizationService.GetResource("Account.ChangePassword.Errors.OldPasswordIsNotProvided", false));
            }
            if (string.IsNullOrWhiteSpace(request.NewPassword))
                result.AddError(_localizationService.GetResource("Account.ChangePassword.Errors.PasswordIsNotProvided", false));
            if (!result.Success) return result;

            // lấy ra customer theo email, khác: ko cho đổi pass nếu kiểm tra thấy customer là deleted hoặc unactive
            var customer = _customerService.GetCustomerByEmail(request.Email);
            if (customer == null || (request.ValidateRequest && customer.Deleted))
            {
                result.AddError(_localizationService.GetResource("Account.ChangePassword.Errors.EmailNotFound", false));
                return result;
            }

            if (request.ValidateRequest)
            {
                // kiểm tra old password phải đúng
                string oldPassword = null;
                switch (customer.PasswordFormat)
                {
                    case PasswordFormat.Hashed:
                        oldPassword = _encryptionService.CreatePasswordHash(request.OldPassword, customer.PasswordSalt,
                            _customerSettings.HashedPasswordFormat);
                        break;
                    case PasswordFormat.Encrypted:
                        oldPassword = _encryptionService.EncryptText(request.OldPassword, _securitySettings);
                        break;
                    case PasswordFormat.Clear:
                        oldPassword = request.OldPassword;
                        break;
                }
                if (!string.Equals(oldPassword, customer.Password, StringComparison.InvariantCulture))
                {
                    result.AddError(_localizationService.GetResource("Account.ChangePassword.Errors.OldPasswordDoesntMatch", false));
                    return result;
                }

                if (!customer.Active)
                {
                    result.AddError(_localizationService.GetResource("Account.ChangePassword.Errors.IsNotActive", false));
                    return result;
                }
            }

            // ok, đến đây thì mọi kiểm tra đều pass, tiến hành đổi password
            customer.PasswordFormat = request.NewPasswordFormat;
            SetPasswordValue(customer, request.NewPassword);

            _customerService.UpdateCustomer(customer);
            return result;
        }