private async Task <bool> CreateAccount(RSAccountForm account, RsWebHelper rsHelper) { if (account != null) { var captchaRes = await GetCaptchaSolveKey(account, rsHelper); if (captchaRes != string.Empty) { account.CaptchaSolve = captchaRes; StatusUpdate (ServiceStatusCode.Updated, account, "Creating account..."); var response = await rsHelper.PostRequest(account); var errorMessage = GetErrorMessage(response); if (errorMessage != string.Empty) { StatusUpdate(ServiceStatusCode.Updated, account, errorMessage); } var success = IsCreateSuccess(response); if (!success && errorMessage == string.Empty) { StatusUpdate(ServiceStatusCode.Updated, account, "An unknown error occured"); Util.Log(response); } return(success); } } return(false); }
private async Task <bool> UnlockAccount(RSRecoveryForm recovery, RsWebHelper rsHelper) { var captchaRes = await GetCaptchaSolveKey(recovery, rsHelper); if (captchaRes == string.Empty) { return(false); } recovery.CaptchaSolve = captchaRes; StatusUpdate(ServiceStatusCode.Updated, recovery, "Requesting account recovery"); var response = await rsHelper.PostRequest(recovery); if (!response.Contains("Account Identified")) { StatusUpdate(ServiceStatusCode.Updated, recovery, "An error occured requesting recovery page"); return(false); } var requestTime = DateTime.Now; var redirectUrl = GetUnlockUrl(response); response = (await rsHelper.GetRequest(redirectUrl)).message; if (!response.Contains("Proceeded to e-mail confirmation screen")) { StatusUpdate(ServiceStatusCode.Updated, recovery, "An error occured requesting account recovery"); return(false); } StatusUpdate(ServiceStatusCode.Updated, recovery, "Connecting to mail provider"); var mail = new MailHelper(MailProvider.Gmail); if (!mail.Connect (recovery.MasterEmail ?? recovery.Email, recovery.EmailPassword)) { StatusUpdate(ServiceStatusCode.Updated, recovery, "Failed to connect to mail provider"); return(false); } StatusUpdate (ServiceStatusCode.Updated, recovery, "Searching for activation mail"); var messageContent = string.Empty; for (int i = 0; i < 30; i++) { messageContent = mail.FindMailBySubjToHtml("Reset your Jagex password", requestTime); if (messageContent != string.Empty) { break; } Thread.Sleep(5 * 1000); } if (messageContent == string.Empty) { StatusUpdate(ServiceStatusCode.Updated, recovery, "Unable to find recovery mail"); return(false); } var resetPassUrl = GetResetPassUrl(messageContent); if (resetPassUrl == string.Empty) { StatusUpdate(ServiceStatusCode.Updated, recovery, "Error obtaining Password Reset link from email"); return(false); } var passResetRequest = await rsHelper.GetRequest(resetPassUrl); if (passResetRequest.response == null) { StatusUpdate(ServiceStatusCode.Updated, recovery, "Error obtaining Password Reset page"); return(false); } var passResetPage = passResetRequest.response.RequestMessage.RequestUri; var accountId = GetAccountId(passResetPage.AbsoluteUri); recovery.AccountId = accountId; recovery.RequestUrl = passResetPage.AbsoluteUri; recovery.RecoveryStage = AccRecoveryStage.Complete; response = await rsHelper.PostRequest(recovery); return(response.Contains("Successfully set a new password and completed the process")); }