Beispiel #1
0
        }//LoginPage()

        public async void ForgotPassword()
        {
            var s = await UserDialogs.Instance.PromptAsync(new PromptConfig
            {
                Message = "Enter E-Mail",
                Placeholder = "*****@*****.**",
                InputType = InputType.Email
            });
            var stat = s.Ok ? "Success" : "Cancelled";
            // System.Diagnostics.Debug.WriteLine(stat, s);
           
            if (stat == "Success")
            {
                System.Diagnostics.Debug.WriteLine(stat + s.Text);

                try
                {
                    UserItem user = new UserItem { Item = new UserLogin { Email = s.Text.TrimEnd().ToLower(), Arn = "" + Helpers.Settings.EndpointArnSetting } };
                    MessageJson messageJson = new MessageJson { operation = "forgotPassword", tableName = "User", payload = user };
                    string args = JsonConvert.SerializeObject(messageJson);

                    //System.Diagnostics.Debug.WriteLine(args);
                    var ir = new InvokeRequest()
                    {
                        FunctionName = Constants.AWSLambdaID,
                        PayloadStream = AWSSDKUtils.GenerateMemoryStreamFromString(args),
                        InvocationType = InvocationType.RequestResponse
                    };
                    //System.Diagnostics.Debug.WriteLine("Before invoke: " + ir.ToString());

                    InvokeResponse resp = await AmazonUtils.LambdaClient.InvokeAsync(ir);
                    resp.Payload.Position = 0;
                    var sr = new StreamReader(resp.Payload);
                    var myStr = sr.ReadToEnd();

                    System.Diagnostics.Debug.WriteLine("Status code: " + resp.StatusCode);
                    System.Diagnostics.Debug.WriteLine("Response content: " + myStr);

                    response tmp = JsonConvert.DeserializeObject<response>(myStr);
                    //System.Diagnostics.Debug.WriteLine("Success: " + tmp.Success);

                    if (tmp.Success == "true")
                    {
                        UserDialogs.Instance.ShowSuccess("Your password has been reset. Please check your email.");

                    }
                    else
                    {
                        UserDialogs.Instance.ShowError("Incorrect email. Please try again.");
                    }

                //                System.Diagnostics.Debug.WriteLine("Status code: " + resp.StatusCode);
                //                System.Diagnostics.Debug.WriteLine("Response content: " + myStr);
                }
                catch (Exception e)
                {
                    System.Diagnostics.Debug.WriteLine("Error:" + e);
                }

            }
        }
Beispiel #2
0
        async private Task PushUser() 
        {
            //Function to create a Json object and send to server using a lambda function
                getLocation();
                try
                {
                    UserItem user = new UserItem { Item = new UserLogin { Latitude = latitude, Longitude = longitude, Password = password.Text, Email = email.Text.ToLower(), Arn = "" + Helpers.Settings.EndpointArnSetting } };
                    MessageJson messageJson = new MessageJson { operation = "update", tableName = "User", payload = user };
                    string args = JsonConvert.SerializeObject(messageJson);
                    //System.Diagnostics.Debug.WriteLine(args);
                    var ir = new InvokeRequest()
                    {
                        FunctionName = Constants.AWSLambdaID,
                        PayloadStream = AWSSDKUtils.GenerateMemoryStreamFromString(args),
                        InvocationType = InvocationType.RequestResponse
                    };
                    //System.Diagnostics.Debug.WriteLine("Before invoke: " + ir.ToString());


                    InvokeResponse resp = await AmazonUtils.LambdaClient.InvokeAsync(ir);
                    resp.Payload.Position = 0;
                    var sr = new StreamReader(resp.Payload);
                    var myStr = sr.ReadToEnd();

                    System.Diagnostics.Debug.WriteLine("Status code: " + resp.StatusCode);
                    System.Diagnostics.Debug.WriteLine("Response content: " + myStr);

                    response tmp = JsonConvert.DeserializeObject<response>(myStr);
                    //System.Diagnostics.Debug.WriteLine("Success: " + tmp.Success);

                    if (tmp.Success == "true")
                    {
                        Helpers.Settings.LoginSetting = true;
                        ((RootPage)App.Current.MainPage).NavigateTo();
                        if (tmp.ActualUserType == "Volunteer")
                        {
                            Helpers.Settings.IsVolunteer = true;
                        }
                        Helpers.Settings.EmailSetting = email.Text;
                        Helpers.Settings.UserIDSetting = tmp.ID;
                        Helpers.Settings.UsernameSetting = tmp.OldNickname;
                    }
                    else
                    {
                        UserDialogs.Instance.ShowError("Incorrect credentials. Please try again.");
                    }

                }
                catch (Exception e)
                {
                    System.Diagnostics.Debug.WriteLine("Error:" + e);
                }
        }
Beispiel #3
0
        //-------------------------Server----------------------------------
        async private Task PushMessage(string text) //Function to create a Json object and send to server using a lambda function
        {
            try
            {
                MessageItem message = new MessageItem { Item = new ChatMessage { ToFrom = Helpers.Settings.ToFromArn, Text = text } };
                MessageJson messageJson = new MessageJson { operation = "create", tableName = "Message", payload = message };
                string args = JsonConvert.SerializeObject(messageJson);
                //System.Diagnostics.Debug.WriteLine(args);
                var ir = new InvokeRequest()
                {
                    FunctionName = Constants.AWSLambdaID,
                    PayloadStream = AWSSDKUtils.GenerateMemoryStreamFromString(args),
                    InvocationType = InvocationType.RequestResponse
                };
                //System.Diagnostics.Debug.WriteLine("Before invoke: " + ir.ToString());


                InvokeResponse resp = await AmazonUtils.LambdaClient.InvokeAsync(ir);
                resp.Payload.Position = 0;
                var sr = new StreamReader(resp.Payload);
                var myStr = sr.ReadToEnd();

                //                System.Diagnostics.Debug.WriteLine("Status code: " + resp.StatusCode);
                //                System.Diagnostics.Debug.WriteLine("Response content: " + myStr);
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine("Error: " + e);
            }
        }
Beispiel #4
0
      /// <summary>
      /// Send user information such as email, username, and password to the server, checking if the account is created.
      /// </summary>
      /// <param name="sender"></param>
      /// <param name="e"></param>
        async private void CreateAccount_Clicked(object sender, System.EventArgs e)
        {
            if (Helpers.Settings.SpeechSetting == true)
            {
                CrossTextToSpeech.Current.Speak("Create Account");
            }

            await getLocation();
            if(String.IsNullOrWhiteSpace(nickname.Text) || String.IsNullOrWhiteSpace(email.Text) || String.IsNullOrEmpty(password.Text))
            {
                UserDialogs.Instance.ShowError("Please enter correct information in all fields.");
            }
            else
            {
                try
                {
                    UserItem user = new UserItem { Item = new UserLogin { Nickname = nickname.Text, Email = email.Text.ToLower(), Password = password.Text,Longitude = longitude, Latitude = latitude, UserType = usertype } };
                    MessageJson messageJson = new MessageJson { operation = "create", tableName = "User", payload = user };
                    string args = JsonConvert.SerializeObject(messageJson);
                    //System.Diagnostics.Debug.WriteLine(args);
                    var ir = new InvokeRequest()
                    {
                        FunctionName = Constants.AWSLambdaID,
                        PayloadStream = AWSSDKUtils.GenerateMemoryStreamFromString(args),
                        InvocationType = InvocationType.RequestResponse
                    };
                    //System.Diagnostics.Debug.WriteLine("Before invoke: " + ir.ToString());

                    InvokeResponse resp = await AmazonUtils.LambdaClient.InvokeAsync(ir);
                    resp.Payload.Position = 0;
                    var sr = new StreamReader(resp.Payload);
                    var myStr = sr.ReadToEnd();

                    UserDialogs.Instance.ShowLoading();
                    UserDialogs.Instance.SuccessToast("Thank you for signing up!", "Please check your email for verification.", 3000);
                    ((RootPage)App.Current.MainPage).NavigateTo();
                    Helpers.Settings.UsernameSetting = nickname.Text;
                    Helpers.Settings.EmailSetting = email.Text;

                    //                System.Diagnostics.Debug.WriteLine("Status code: " + resp.StatusCode);
                    System.Diagnostics.Debug.WriteLine("Response content: " + myStr);
                }
                catch (Exception e2)
                {
                    System.Diagnostics.Debug.WriteLine("Error:" + e2);
                }
            }

        }
Beispiel #5
0
        //==================================================== update password on server ==============================================================

        public async void updatePassword(String oldPass, String newPass)
        {
            if (Helpers.Settings.SpeechSetting == true)
            {
                CrossTextToSpeech.Current.Speak("Change Password");
            }

            try
            {
                UserItem user = new UserItem { Item = new UserLogin { Email = Helpers.Settings.EmailSetting.ToLower(), Password = oldPass.TrimEnd(), NewPassword = newPass, Arn = "" + Helpers.Settings.EndpointArnSetting } };
                MessageJson messageJson = new MessageJson { operation = "update", tableName = "User", payload = user };
                string args = JsonConvert.SerializeObject(messageJson);

                //System.Diagnostics.Debug.WriteLine(args);
                var ir = new InvokeRequest()
                {
                    FunctionName = Constants.AWSLambdaID,
                    PayloadStream = AWSSDKUtils.GenerateMemoryStreamFromString(args),
                    InvocationType = InvocationType.RequestResponse
                };
                //System.Diagnostics.Debug.WriteLine("Before invoke: " + ir.ToString());

                InvokeResponse resp = await AmazonUtils.LambdaClient.InvokeAsync(ir);
                resp.Payload.Position = 0;
                var sr = new StreamReader(resp.Payload);
                var myStr = sr.ReadToEnd();

                System.Diagnostics.Debug.WriteLine("Status code: " + resp.StatusCode);
                System.Diagnostics.Debug.WriteLine("Response content: " + myStr);


                UserDialogs.Instance.ShowSuccess("Password updated successfully.");
                await Navigation.PopAsync();
                
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine("Error:" + e);
            }
        }
Beispiel #6
0
        /// <summary>
        /// Logout functionality, sends relevant user information to server to log out and update settings constants
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void Logout_Clicked(object sender, EventArgs e)
        {

            if (Helpers.Settings.SpeechSetting == true)
            {
                CrossTextToSpeech.Current.Speak("Logout");
            }
            try
            {
                System.Diagnostics.Debug.WriteLine(Helpers.Settings.EndpointArnSetting);
                UserItem user = new UserItem { Item = new UserLogin { Arn = Helpers.Settings.EndpointArnSetting } };
                MessageJson messageJson = new MessageJson { operation = "logout", tableName = "User", payload = user };
                string args = JsonConvert.SerializeObject(messageJson);
                //System.Diagnostics.Debug.WriteLine(args);
                var ir = new InvokeRequest()
                {
                    FunctionName = Constants.AWSLambdaID,
                    PayloadStream = AWSSDKUtils.GenerateMemoryStreamFromString(args),
                    InvocationType = InvocationType.RequestResponse
                };
                //System.Diagnostics.Debug.WriteLine("Before invoke: " + ir.ToString());


                InvokeResponse resp = await AmazonUtils.LambdaClient.InvokeAsync(ir);
                resp.Payload.Position = 0;
                var sr = new StreamReader(resp.Payload);
                var myStr = sr.ReadToEnd();

                System.Diagnostics.Debug.WriteLine("Status code: " + resp.StatusCode);
                System.Diagnostics.Debug.WriteLine("Response content: " + myStr);

                response tmp = JsonConvert.DeserializeObject<response>(myStr);
                if (tmp.Success == "true")
                {
                    Helpers.Settings.IsVolunteer = false;
                    Helpers.Settings.LoginSetting = false;
                    UserDialogs.Instance.ShowSuccess("You have been successfully logged out.");
                    ((RootPage)App.Current.MainPage).NavigateTo();
                }
                else
                {
                    UserDialogs.Instance.ShowError("Unable to log out.");
                }
            }
            catch (Exception e2)
            {
                System.Diagnostics.Debug.WriteLine("Error:" + e2);
            }

        }
Beispiel #7
0
        }//end GeneralAccountPage()

        //=============================================== FUNCTIONS ======================================================

        /// <summary>
        /// When username changes text, it updates username, pushing it onto the server
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void Username_TextChanged(object sender, TextChangedEventArgs e)
        {
            Helpers.Settings.UsernameSetting = username.Text;
            try
            {
                UserItem user = new UserItem { Item = new UserLogin { Nickname = username.Text } };
                MessageJson messageJson = new MessageJson { operation = "update", tableName = "User", payload = user };
                string args = JsonConvert.SerializeObject(messageJson);
                //System.Diagnostics.Debug.WriteLine(args);
                var ir = new InvokeRequest()
                {
                    FunctionName = Constants.AWSLambdaID,
                    PayloadStream = AWSSDKUtils.GenerateMemoryStreamFromString(args),
                    InvocationType = InvocationType.RequestResponse
                };
                //System.Diagnostics.Debug.WriteLine("Before invoke: " + ir.ToString());


                InvokeResponse resp = await AmazonUtils.LambdaClient.InvokeAsync(ir);
                resp.Payload.Position = 0;
                var sr = new StreamReader(resp.Payload);
                var myStr = sr.ReadToEnd();

            }
            catch (Exception e2)
            {
                System.Diagnostics.Debug.WriteLine("Error:" + e2);
            }

        }