async partial void Authenticate(UIButton _)
        {
            var email = EmailTextField.Text;
            var passw = PasswordTextField.Text;

            if (string.IsNullOrWhiteSpace(email))
            {
                ErrorMessageDialog(StringResources.common_ui_forms_email_validate_empty);
            }
            else if (string.IsNullOrWhiteSpace(passw))
            {
                ErrorMessageDialog(StringResources.common_ui_forms_password_validate_empty);
            }
            else if (!Regex.Match(email, @"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$").Success)
            {
                ErrorMessageDialog(StringResources.common_ui_forms_email_validate_invalid);
            }
            else
            {
                PasswordTextField.BecomeFirstResponder();
                PasswordTextField.ResignFirstResponder();

                LoginUIButton.Enabled = false;
                var client = new RestClient();
                LoginActivityIndicator.StartAnimating();

                Logger.LOG_EVENT_WITH_ACTION("LOGIN", "ATTEMPT");
                var response = await client.Login(email, passw);

                LoginActivityIndicator.StopAnimating();
                LoginUIButton.Enabled = true;

                if (response.Meta.Messages.Count > 0)
                {
                    Logger.LOG_EVENT_WITH_ACTION("LOGIN", "ERROR");
                    // Only show the first error as there
                    var err = StringResources.ResourceManager.GetString($"login.api.error.{response.Meta.Messages[0]}");
                    ErrorMessageDialog(err);
                }
                else if (!string.IsNullOrEmpty(response.Data?.Tokens.Access))
                {
                    Logger.LOG_EVENT_WITH_ACTION("LOGIN", "SUCCESS");
                    NSUserDefaults.StandardUserDefaults.SetString(JsonConvert.SerializeObject(response.Data.Tokens), "tokens");
                    NSUserDefaults.StandardUserDefaults.SetString(email, "username");

                    Queries.SetActiveUser(response.Data);
                    Analytics.SetUserID(response.Data.User.Id.ToString());

                    UIApplication.SharedApplication.Windows[0].RootViewController =
                        UIStoryboard.FromName("Main", null).InstantiateInitialViewController();
                }
            }
        }
Beispiel #2
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var set = this.CreateBindingSet <RootView, RootViewModel>();

            LoginActivityIndicator.StartAnimating();
            set.Bind(LoginActivityIndicator).For(v => v.Hidden).To(vm => vm.AttemptingLogin).WithConversion(new InverseValueConverter());
            set.Bind(AttemptingLoginLabel).For(b => b.Hidden).To(vm => vm.AttemptingLogin).WithConversion(new InverseValueConverter());
            set.Bind(LoginButton).For(b => b.Hidden).To(vm => vm.AttemptingLogin);
            set.Bind(LoginButton).To(vm => vm.LoginCommand);
            set.Apply();
        }
Beispiel #3
0
        void ReleaseDesignerOutlets()
        {
            if (AttemptingLoginLabel != null)
            {
                AttemptingLoginLabel.Dispose();
                AttemptingLoginLabel = null;
            }

            if (LoginActivityIndicator != null)
            {
                LoginActivityIndicator.Dispose();
                LoginActivityIndicator = null;
            }

            if (LoginButton != null)
            {
                LoginButton.Dispose();
                LoginButton = null;
            }
        }
        void ReleaseDesignerOutlets()
        {
            if (Login != null)
            {
                Login.Dispose();
                Login = null;
            }

            if (LoginActivityIndicator != null)
            {
                LoginActivityIndicator.Dispose();
                LoginActivityIndicator = null;
            }

            if (Password != null)
            {
                Password.Dispose();
                Password = null;
            }

            if (Server != null)
            {
                Server.Dispose();
                Server = null;
            }

            if (SuccessLabel != null)
            {
                SuccessLabel.Dispose();
                SuccessLabel = null;
            }

            if (Username != null)
            {
                Username.Dispose();
                Username = null;
            }
        }
        void ReleaseDesignerOutlets()
        {
            if (EmailTextField != null)
            {
                EmailTextField.Dispose();
                EmailTextField = null;
            }

            if (LoginActivityIndicator != null)
            {
                LoginActivityIndicator.Dispose();
                LoginActivityIndicator = null;
            }

            if (LoginErrorLabel != null)
            {
                LoginErrorLabel.Dispose();
                LoginErrorLabel = null;
            }

            if (LoginMasterView != null)
            {
                LoginMasterView.Dispose();
                LoginMasterView = null;
            }

            if (LoginUIButton != null)
            {
                LoginUIButton.Dispose();
                LoginUIButton = null;
            }

            if (PasswordTextField != null)
            {
                PasswordTextField.Dispose();
                PasswordTextField = null;
            }
        }