public void forgot()
        {
            Util.Response response = Util.request(new Util.Request
            {
                TARGET = "forgot",
                METHOD = RestSharp.Method.POST,
                DATA   = new
                {
                    ID = user.Text
                }
            });

            if (response.success == "True")
            {
                statusLabel.Text = "Logged in:";
                foreach (var key in response.headers)
                {
                    if (key.ToString().Contains("Set-Cookie"))
                    {
                        statusLabel.Text = "Instructions sent to your email";
                    }
                }
            }
            else
            {
                statusLabel.Text = response.raw;
            }
        }
        public void signup()
        {
            statusLabel.Text = "Signup Attempt";

            Util.Response response = Util.request(new Util.Request
            {
                TARGET = "register",
                METHOD = RestSharp.Method.POST,
                DATA   = new
                {
                    USERNAME     = user.Text,
                    EMAIL        = email.Text,
                    PASSWORD     = pass.Text,
                    DISPLAY_NAME = display.Text
                }
            });

            if (response.success == "True")
            {
                foreach (var key in response.headers)
                {
                    if (key.ToString().Contains("Set-Cookie"))
                    {
                        var cookies = Util.parseCookies(key.Value.ToString());

                        Application.Current.Properties["CID"] = cookies["CID"].VALUE;
                        Application.Current.Properties["SID"] = cookies["SID"].VALUE;
                        Application.Current.SavePropertiesAsync();

                        App.PAGE             = "MEPAGE";
                        App.Current.MainPage = new Commservus_Mobile.MePage_();
                    }
                }
            }
            else
            {
                statusLabel.Text = response.raw;
            }
        }
Пример #3
0
        public MainPage()
        {
            /**
             * Background Manipulations
             **/
            BackgroundColor = Util.GREY;
            layout          = new AbsoluteLayout();



            /**
             * Borders
             **/
            BoxView leftBorder = new BoxView
            {
                Color         = Util.GREEN,
                WidthRequest  = 150,
                HeightRequest = 100,
            };

            AbsoluteLayout.SetLayoutFlags(leftBorder, AbsoluteLayoutFlags.All);
            AbsoluteLayout.SetLayoutBounds(leftBorder, new Rectangle(-.1f, 1f, .55f, .15f));

            BoxView rightBorder = new BoxView
            {
                Color         = Util.GREEN,
                WidthRequest  = 150,
                HeightRequest = 100,
            };

            AbsoluteLayout.SetLayoutFlags(rightBorder, AbsoluteLayoutFlags.All);
            AbsoluteLayout.SetLayoutBounds(rightBorder, new Rectangle(1.1f, 1.01f, .55f, .16f));



            /**
             * Login Button
             **/
            BoxView loginBox = new BoxView
            {
                Color         = Util.GREEN,
                WidthRequest  = 150,
                HeightRequest = 100,
            };

            AbsoluteLayout.SetLayoutFlags(loginBox, AbsoluteLayoutFlags.All);
            AbsoluteLayout.SetLayoutBounds(loginBox, new Rectangle(-.1f, 1.01f, .55f, .15f));

            Label loginLbl = new Label
            {
                Text       = "Login",
                FontSize   = 35,
                FontFamily = fontFamily,
                TextColor  = Color.White,
            };

            AbsoluteLayout.SetLayoutFlags(loginLbl, AbsoluteLayoutFlags.PositionProportional);
            AbsoluteLayout.SetLayoutBounds(loginLbl, new Rectangle(.15f, .95f, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize));

            var loginTapGestureRecognizer = new TapGestureRecognizer();

            loginTapGestureRecognizer.Tapped += (s, e) =>
            {
                App.Current.MainPage = new LoginPage();
                App.PAGE             = "LOGIN";
            };

            loginBox.GestureRecognizers.Add(loginTapGestureRecognizer);
            loginLbl.GestureRecognizers.Add(loginTapGestureRecognizer);



            /**
             * Signup Button
             **/
            BoxView signUpBox = new BoxView
            {
                Color         = Util.ORANGE,
                WidthRequest  = 150,
                HeightRequest = 100,
            };

            AbsoluteLayout.SetLayoutFlags(signUpBox, AbsoluteLayoutFlags.All);
            AbsoluteLayout.SetLayoutBounds(signUpBox, new Rectangle(1.1f, 1.01f, .55f, .15f));

            Label signUpLbl = new Label
            {
                Text       = "Sign Up",
                FontSize   = 36,
                FontFamily = fontFamily,
                TextColor  = Color.White,
            };

            AbsoluteLayout.SetLayoutFlags(signUpLbl, AbsoluteLayoutFlags.PositionProportional);
            AbsoluteLayout.SetLayoutBounds(signUpLbl, new Rectangle(.85f, .95f, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize));

            var signUpTapGestureRecognizer = new TapGestureRecognizer();

            signUpTapGestureRecognizer.Tapped += (s, e) =>
            {
                App.Current.MainPage = new SignUpPage();
                App.PAGE             = "SIGNUP";
            };
            signUpBox.GestureRecognizers.Add(signUpTapGestureRecognizer);
            signUpLbl.GestureRecognizers.Add(signUpTapGestureRecognizer);

            /**
             * Compiling Components
             **/
            layout = new AbsoluteLayout
            {
                Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5),

                Children =
                {
                    loginBox,
                    loginLbl,
                    signUpBox,
                    signUpLbl
                }
            };

            this.Content = layout;

            try
            {
                Util.Response vResponse = Util.request(new Util.Request
                {
                    METHOD = Method.GET,
                    TARGET = "valid",
                    DATA   = new { }
                });

                if (vResponse.success.ToLower() == "true")
                {
                    signUpLbl.FontSize = 8;
                    signUpLbl.Text     = "We logging in";
                    redirect           = true;

                    api.APIHandler.ValidResponse response = JsonConvert.DeserializeObject <api.APIHandler.ValidResponse>(vResponse.raw);
                    api.APIHandler.myAccount = response.data;

                    //App.Current.MainPage = new Commservus_Mobile.SignUpPage();
                }
                else
                {
                    //App.Current.MainPage = new Commservus_Mobile.MainPage();
                }

                api.APIHandler.loadFeed();
            }
            catch (Exception ex)
            {
                signUpLbl.FontSize = 8;
                signUpLbl.Text     = ex.Message;
            }
        }