예제 #1
0
 void NavigationSetup()
 {
     Messenger.Default.Register <NavigateArgs>(this, (x) =>
     {
         LoginFrame.Navigate(new Uri(x.Url, UriKind.Relative));
     });
 }
 public LoginControl()
 {
     this.InitializeComponent();
     if (!String.IsNullOrWhiteSpace(AppSettings.Current.Username))
     {
         LoginFrame.Navigate(typeof(LoginPage), true);
     }
     else
     {
         LoginFrame.Navigate(typeof(RegisterPage));
     }
 }
예제 #3
0
        public void PassportSignInButton_Click(object sender, RoutedEventArgs e)
        {
            string username         = UsernameTextBox.Text;
            string passwords        = PasswordsTextBox.Password;
            string connectionString = "Data Source=SURFACELAPTOP;Initial Catalog=创新创业管理系统;Persist Security Info=True;User ID=" + username + ";Password=" + passwords;

            try
            {
                SqlConnection conn = new SqlConnection(connectionString);
                conn.Open();
                LoginFrame.Navigate(typeof(ShellPage));
            }
            catch (Exception error)
            {
                DisplayLoginFailedDialog(error.ToString());
            }
        }
예제 #4
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            if (_dashboardViewModel == null)
            {
                _dashboardViewModel = new DashboardViewModel(Dispatcher, OnLogoutNavigation);
                ContentFrame.Navigate(typeof(DashboardPage), _dashboardViewModel);
            }

            if (_loginViewModel == null)
            {
                _loginViewModel = new LoginViewModel(OnAuthenticatedNavigation);
                LoginFrame.Navigate(typeof(LoginPage), _loginViewModel);
            }

            if (e.Parameter is IncidentSelectedEventArgs)
            {
                _dashboardViewModel.NavigateToDetailsPane(this, e.Parameter as IncidentSelectedEventArgs);
            }
        }
예제 #5
0
        public async void Login_Click(object sender, RoutedEventArgs e)
        {
            //base.OnNavigatedTo(e);
            //var Info = (UserInfo)e.OriginalSource;
            //Will explain it later
            //    //UserName Validation


            if (!Regex.IsMatch(UserName.Text.Trim(), @"^[A-Za-z_][a-zA-Z0-9_\s]*$"))
            {
                //MessageBox.Show("Invalid UserName");
                var dialog = new MessageDialog("Invalid UserName");
                await dialog.ShowAsync();
            }
            //Password length Validation
            else if (PassWord.Password.Length < 6)
            {
                //MessageBox.Show("Password length should be minimum of 6 characters!");
                var dialog = new MessageDialog("Password length is greater than 6 characters!");
                await dialog.ShowAsync();
            }
            //    //After validation success ,store user detials and also check information
            else if (UserName.Text != "" && PassWord.Password != "")
            {
                var firebase = new FirebaseClient("https://calendarbot-2573c.firebaseio.com/");
                var username = await firebase
                               .Child("users")
                               .OnceAsync <UserName>();

                MainPage.log = UserName.Text;
                int num = 0;

                bool find = false;
                //res.GetAt(1);
                //var passW = await firebase
                //  .Child("users")
                //  .Child(UserName.Text)
                //  .Child("password")
                //  .Child(PassWord.Password)
                //  .OnceSingleAsync<UserPass>();

                //string passy3 = passW.pass;



                string     urlParameters = "https://calendarbot-2573c.firebaseio.com/users/" + UserName.Text + "/password.json";
                HttpClient client        = new HttpClient();

                HttpResponseMessage response = client.GetAsync(urlParameters).Result;

                string responseBody = await response.Content.ReadAsStringAsync();

                if (response.IsSuccessStatusCode)
                {
                    string pa   = PassWord.Password;
                    var    json = JObject.Parse(responseBody);
                    //string passy4 = json.p.value;
                    var first = json.Properties().Select(p => p.Name).FirstOrDefault();
                    if (first == PassWord.Password)
                    {
                        find = true;
                    }
                }


                foreach (var u in username)
                {
                    if (u.Key == UserName.Text)
                    {
                        //var dialog = new MessageDialog("Invalid Username");
                        //await dialog.ShowAsync();
                        //foreach (var p in passW)
                        //{
                        //    if (p.Key == PassWord.Password)
                        //    {
                        //        MainPage.accessPage = true;
                        //        LoginFrame.Navigate(typeof(MainPage));

                        //    }
                        //    else
                        //    {
                        //        var dialog = new MessageDialog("Invalid password");
                        //        await dialog.ShowAsync();
                        //    }
                        //}
                        //var user = UserName.Text;
                        //var Info = new UserInfo();
                        //Info.info = UserName.Text;

                        //MainPage.accessPage = true;

                        //var vault = new Windows.Security.Credentials.PasswordVault();
                        //vault.Add(new Windows.Security.Credentials.PasswordCredential(
                        //    "CalendarBot", UserName.Text, PassWord.Password));

                        if (find == true)
                        {
                            MainPage.accessPage = true;
                            LoginFrame.Navigate(typeof(MainPage));
                        }
                        //MainPage.accessPage = true;
                        //LoginFrame.Navigate(typeof(MainPage));
                    }

                    if (num == 0 && u.Key != UserName.Text)
                    {
                        var dialog = new MessageDialog("Wrong username or password");
                        await dialog.ShowAsync();

                        num++;
                        //SignUpFrame.Navigate(typeof(MainPage));
                    }
                }
            }
        }
예제 #6
0
 public void SignUp_Click(object sender, RoutedEventArgs e)
 {
     LoginFrame.Navigate(typeof(signUp));
 }
예제 #7
0
        public async void Login_Click(object sender, RoutedEventArgs e)
        {
            if (!Regex.IsMatch(UserName.Text.Trim(), @"^[A-Za-z_][a-zA-Z0-9_\s]*$"))
            {
                //MessageBox.Show("Invalid UserName");
                var dialog = new MessageDialog("Invalid UserName");
                await dialog.ShowAsync();
            }
            //Password length Validation
            else if (PassWord.Password.Length < 6)
            {
                //MessageBox.Show("Password length should be minimum of 6 characters!");
                var dialog = new MessageDialog("Password length is greater than 6 characters!");
                await dialog.ShowAsync();
            }
            //    //After validation success ,store user detials and also check information
            else if (UserName.Text != "" && PassWord.Password != "")
            {
                var firebase = new FirebaseClient("https://calendarbot-2573c.firebaseio.com/");
                var username = await firebase
                               .Child("users")
                               .OnceAsync <UserName>();

                MainPage.log = UserName.Text;

                bool       find          = false;
                bool       err           = false;
                string     urlParameters = "https://calendarbot-2573c.firebaseio.com/users/" + UserName.Text + "/password.json";
                HttpClient client        = new HttpClient();

                HttpResponseMessage response = client.GetAsync(urlParameters).Result;

                string responseBody = await response.Content.ReadAsStringAsync();

                if (responseBody != "null")
                {
                    if (response.IsSuccessStatusCode)
                    {
                        string pa    = PassWord.Password;
                        var    json  = JObject.Parse(responseBody);
                        var    first = json.Properties().Select(p => p.Name).FirstOrDefault();
                        if (first == PassWord.Password)
                        {
                            find = true;
                        }
                    }
                }
                else
                {
                    var dialog = new MessageDialog("Wrong username or password");
                    await dialog.ShowAsync();
                }


                foreach (var u in username)
                {
                    if (u.Key == UserName.Text && find == true)
                    {
                        MainPage.accessPage = true;
                        LoginFrame.Navigate(typeof(MainPage));
                    }
                    else if (u.Key == UserName.Text && find != true)
                    {
                        err = true;
                    }
                }

                if (err == true)
                {
                    var dialog = new MessageDialog("Wrong username or password");
                    await dialog.ShowAsync();
                }
            }
        }