public void ResendMobileCode(Account account) { string verificationCode = VerificationCodeGenerator.GenerateNewVerificationCode(); bool isSuccessful = false; if (!Configuration.IsMobileMock) { var helper = new RequestResponseBuilder(); string url = string.Format( Configuration.MobileVerificationBaseUrl + Configuration.MobileVerificationFormat, account.Mobile, verificationCode); WebRequest request = helper.CreateRequest<WebRequest>(url, null); string responseString; WebResponse response = helper.GetResponse(request, out responseString); if (response != null && !string.IsNullOrEmpty(responseString)) { isSuccessful = true; } } else { verificationCode = "123456"; isSuccessful = true; } if (isSuccessful) { ICodeVerificationDataProvider codeVerificationDataProvider = CodeVerificationDataProviderFactory.CreateCodeVerificationDataProvider(); if (codeVerificationDataProvider.Remove(account.AccountId, Type)) { codeVerificationDataProvider.SaveNewCode(account.AccountId, verificationCode, Type); } } }
public bool Validate(string challenge, string ipAddress, string response) { if (challenge == "test" && response == "test") return true; try { string postValue = string.Format("privatekey={0}&remoteip={1}&challenge={2}&response={3}", Configuration.ReCaptchaPrivateKey, ipAddress, challenge, response); using (var connector = new RequestResponseBuilder()) { WebRequest request = connector.CreateRequest<HttpWebRequest>(Configuration.ReCaptchaUrl, postValue, "POST"); string responsesString; connector.GetResponse(request, out responsesString); if (!string.IsNullOrEmpty(responsesString) && responsesString.Contains("true")) return true; } } catch (Exception ex) { Logger.LogException(ex, Source, "SendRegistrationEmail", Severity.Major); } return false; }