/// <summary>
        /// Nos redirije a la pagina del login
        /// </summary>
        /// <param name="obj"></param>
        private async void OnAuthenticateCommand(object obj)
        {
            if (GlobalSetting.GetInstance().Users == null)
            {
                await PageDialog.AlertAsync("No fue posible acceder sin datos, recarga otra vez la pagina", "Error", "Aceptar");

                return;
            }
            await _navigationService.NavigateTo($"///login");
        }
        /// <summary>
        /// Valida si se autentico y lo dijire hacia Home
        /// </summary>
        /// <param name="obj"></param>
        private async void OnLoginCommand(object obj)
        {
            var userAuth = GlobalSetting.GetInstance().Users.Find(a => a.Username == this.User && a.Password == this.Pass);

            if (userAuth == null)
            {
                await this.PageDialog.AlertAsync("No se pudo encontrar ningun usuario", "Error", "Aceptar");

                return;
            }
            GlobalSetting.GetInstance().UserAuth = userAuth;
            MessagingCenter.Send("Ok", MessagingKeys.RegisterUser);
            await _navigationService.NavigateTo($"///home");
        }
        private async void Login()
        {
            // This is where you would probably check the login and only if valid do the navigation...
            if (string.IsNullOrEmpty(Username) || string.IsNullOrEmpty(Password))
            {
                await App.Current.MainPage.DisplayAlert("Thông báo", "Tên đăng nhập và mật khẩu không được bỏ trống!", "ok");
            }
            else
            {
                var account = new { username = Username, password = Password };
                DataLogin = await usersServices.CheckLoginAsync(account);

                if (DataLogin is null)
                {
                    await App.Current.MainPage.DisplayAlert("Thông báo", "Tên đăng nhập hoặc mật khẩu không chính xác!", "ok");
                }
                else
                {
                    await App.Current.MainPage.DisplayAlert("Thông báo", "Đăng nhập thành công", "ok");

                    Application.Current.Properties["firstName"] = DataLogin.data.firstName;
                    Application.Current.Properties["lastName"]  = DataLogin.data.lastName;
                    Application.Current.Properties["userId"]    = DataLogin.data.id;
                    await SecureStorage.SetAsync("oauthtoken", DataLogin.data.accessToken);

                    await SecureStorage.SetAsync("isLogged", "1");

                    Application.Current.MainPage = new AppShell();
                    await _navigationService.NavigateTo("///main/overview");
                }
            }
        }
        //private void Login()
        //{
        //    // This is where you would probably check the login and only if valid do the navigation...
        //    //var isAuthenticated = await this.identityService.Authenticate();

        //    if (Username == "ramon" && Password == "123123")
        //    {
        //        _navigationService.NavigateTo("///main/home");
        //    }
        //    else
        //        _navigationService.NavigateTo("///main/error");
        //}

        private async void Login()
        {
            // This is where you would probably check the login and only if valid do the navigation...
            var isAuthenticated = await this.identityService.Login(Username, Password);

            User _user    = (User)isAuthenticated;
            var  jsonUser = JsonConvert.SerializeObject(isAuthenticated);

            if (_user != null && _user.ID > 0)
            {
                await _navigationService.NavigateTo($"///main/home?user={jsonUser}");
            }
            else
            {
                await _navigationService.NavigateTo("///main/error");
            }
        }
 private async void Register()
 {
     await _navigationService.NavigateTo("//main");
 }
 private void Login()
 {
     // This is where you would probably check the login and only if valid do the navigation...
     _navigationService.NavigateTo("///main/home");
 }
Beispiel #7
0
 // Ve el detalle del usuario
 private async void OnSelectUserCommand(HomeModel user)
 {
     GlobalSetting.GetInstance().UserSelect = user;
     MessagingCenter.Send("Ok", MessagingKeys.UserSelected);
     await _navigationService.NavigateTo($"///datauser");
 }
Beispiel #8
0
 // Vuelve a la pagina anterior
 private async void OnBackCommand(object obj)
 {
     await _navigationService.NavigateTo($"///users");
 }