예제 #1
0
        public ActionResult Index(LoginViewModel loginViewModel)
        {
            if (ModelState.IsValid)
            {
                loginViewModel.login.username = loginViewModel.Username;
                loginViewModel.login.password = loginViewModel.Password;

                try
                {
                    if (loginClient.DoesUserExist(loginViewModel.login))
                    {
                        ModelState.AddModelError("", "Sorry, we can't find you in our system, please try again or register");
                    }
                    else
                    {
                        loginClient.DecryptPassword(loginViewModel.login);
                        SessionLogin.UserName = loginViewModel.Username;
                        return(RedirectToAction("MyProfile"));
                    }
                }
                catch (FaultException)
                {
                    ModelState.AddModelError("", "Sorry, we can't find you in our system, please try again or register");
                }
            }
            return(View(loginViewModel));
        }
예제 #2
0
        public ActionResult Login(LoginViewModel loginViewModel)
        {
            if (ModelState.IsValid)
            {
                loginViewModel.login.username = loginViewModel.Username;
                loginViewModel.login.password = loginViewModel.Password;

                try
                {
                    if (loginClient.DoesUserExist(loginViewModel.login))
                    {
                        ModelState.AddModelError("", "Sorry, we can't find you in our system, please try again or register");
                    }
                    else
                    {
                        var login = loginClient.DecryptPassword(loginViewModel.login);

                        CurrentQuizViewModel quizVm = new CurrentQuizViewModel();
                        quizVm.Login.Username = loginViewModel.Username;
                        SessionLogin.UserName = quizVm.Login.Username;
                        return(RedirectToAction("Category"));
                    }
                }
                catch (FaultException)
                {
                    ModelState.AddModelError("", "Sorry, we can't find you in our system, please try again or register");
                }
            }
            return(View(loginViewModel));
        }
예제 #3
0
        private void Login()
        {
            Home  home  = new Home();
            Login login = new Login();

            login.username = usernameTextbox.Text;
            login.password = passwordBox.Password;
            if (!string.IsNullOrEmpty(login.username) && !string.IsNullOrEmpty(login.password))
            {
                try
                {
                    if (loginClient.DoesUserExist(login))
                    {
                        MessageBox.Show("Could not find the login in the system", "Failed attempt", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                    else
                    {
                        var currentLogin = loginClient.DecryptPassword(login);
                        if (currentLogin != null)
                        {
                            MessageBox.Show("Successfully logged in", "Success", MessageBoxButton.OK, MessageBoxImage.Asterisk);
                            home.Show();
                            Close();
                        }
                    }
                }
                catch (FaultException)
                {
                    MessageBox.Show("Could not find the login in the system", "Failed attempt", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            else
            {
                MessageBox.Show("Fill out all fields", "Fill out all fields");
            }
        }