コード例 #1
0
        // 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);
        }
コード例 #2
0
        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
                        };
                        System.Diagnostics.Debug.WriteLine("password algo: " + userInformation.password_algorithm);
                        Preferences.Set("password_algorithm", userInformation.password_algorithm);
                        System.Diagnostics.Debug.WriteLine("password algo stored: " + Preferences.Get("password_algorithm", ""));
                        System.Diagnostics.Debug.WriteLine("password salt: " + userInformation.password_salt);
                        Preferences.Set("password_salt", userInformation.password_salt);
                        System.Diagnostics.Debug.WriteLine("password salt stored: " + Preferences.Get("password_salt", ""));
                    }
                }
                return(userInformation);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
                return(null);
            }
        }