private async Task <AccountSalt> retrieveAccountSalt(string userEmail) { try { System.Diagnostics.Debug.WriteLine(userEmail); SaltPost saltPost = new SaltPost(); saltPost.email = userEmail; var saltPostSerilizedObject = JsonConvert.SerializeObject(saltPost); var saltPostContent = new StringContent(saltPostSerilizedObject, Encoding.UTF8, "application/json"); System.Diagnostics.Debug.WriteLine(saltPostSerilizedObject); var client = new HttpClient(); var DRSResponse = await client.PostAsync(Constant.AccountSaltUrl, saltPostContent); var DRSMessage = await DRSResponse.Content.ReadAsStringAsync(); System.Diagnostics.Debug.WriteLine(DRSMessage); AccountSalt userInformation = null; if (DRSResponse.IsSuccessStatusCode) { var result = await DRSResponse.Content.ReadAsStringAsync(); AcountSaltCredentials data = new AcountSaltCredentials(); data = JsonConvert.DeserializeObject <AcountSaltCredentials>(result); if (DRSMessage.Contains(Constant.UseSocialMediaLogin)) { createAccount = true; System.Diagnostics.Debug.WriteLine(DRSMessage); await DisplayAlert("Oops!", data.message, "OK"); } else if (DRSMessage.Contains(Constant.EmailNotFound)) { await DisplayAlert("Oops!", "Our records show that you don't have an accout. Please sign up!", "OK"); } else { userInformation = new AccountSalt { password_algorithm = data.result[0].password_algorithm, password_salt = data.result[0].password_salt }; } } return(userInformation); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); return(null); } }
private async Task <AccountSalt> retrieveAccountSalt(string userEmail) { try { System.Diagnostics.Debug.WriteLine(userEmail); SaltPost saltPost = new SaltPost(); saltPost.email = userEmail; var saltPostSerilizedObject = JsonConvert.SerializeObject(saltPost); var saltPostContent = new StringContent(saltPostSerilizedObject, Encoding.UTF8, "application/json"); var client = new HttpClient(); var DRSResponse = await client.PostAsync(Constant.AccountSaltUrl, saltPostContent); AccountSalt userInformation = null; if (DRSResponse.IsSuccessStatusCode) { var result = await DRSResponse.Content.ReadAsStringAsync(); AcountSaltCredentials data = new AcountSaltCredentials(); data = JsonConvert.DeserializeObject <AcountSaltCredentials>(result); userInformation = new AccountSalt { password_algorithm = data.result[0].password_algorithm, password_salt = data.result[0].password_salt }; } return(userInformation); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); return(null); } }
// DIRECT VERIFICATION FUNCTIONS_______________________________________ // This function retrives direct user's account salt credentials. public async Task <AccountSalt> RetrieveAccountSalt(string userEmail) { AccountSalt userInformation = null; try { SaltPost saltPost = new SaltPost(); saltPost.email = userEmail; var saltPostSerilizedObject = JsonConvert.SerializeObject(saltPost); var saltPostContent = new StringContent(saltPostSerilizedObject, Encoding.UTF8, "application/json"); var client = new HttpClient(); var DRSResponse = await client.PostAsync(Constant.AccountSaltUrl, saltPostContent); var DRSMessage = await DRSResponse.Content.ReadAsStringAsync(); if (DRSResponse.IsSuccessStatusCode) { var result = await DRSResponse.Content.ReadAsStringAsync(); AcountSaltCredentials data = new AcountSaltCredentials(); data = JsonConvert.DeserializeObject <AcountSaltCredentials>(result); if (DRSMessage.Contains(Constant.UseSocialMediaLogin)) { userInformation = new AccountSalt { password_algorithm = null, password_salt = null, message = data.message == null ? "" : data.message }; } else if (DRSMessage.Contains(Constant.EmailNotFound)) { userToSignUp = new SignUpAccount(); userToSignUp.email = userEmail.ToLower().Trim(); userToSignUp.platform = "DIRECT"; userInformation = new AccountSalt { password_algorithm = null, password_salt = null, message = "USER NEEDS TO SIGN UP" }; } else { userInformation = new AccountSalt { password_algorithm = data.result[0].password_algorithm, password_salt = data.result[0].password_salt, message = null }; } } } catch (Exception errorRetrieveAccountSalt) { //var client = new Diagnostic(); //client.parseException(errorRetrieveAccountSalt.ToString(), user); Debug.WriteLine("ERROR "); } return(userInformation); }