예제 #1
0
        public ActionResult Login(string inputEmail, string inputPassword)
        {
            User user = client.LoginUser(inputEmail, inputPassword);

            if (user != null)
            {
                try
                {
                    if (inputEmail.Equals(user.Email))
                    {
                        Session["Email"] = inputEmail;
                        Session["ID"]    = user.Id;
                        return(RedirectToAction("Index", "Ads"));
                    }
                }
                //catch hvis de skriver forkert brugernavn/kode
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    throw;
                }
            }
            else
            {
                ViewBag.Error = "der er sket en fejl";
            }
            return(View());
        }
예제 #2
0
        public void TestLogin()
        {
            User u1 = new User
            {
                Address = "test",
                Age     = "1",
                Salt    = crypto.GenerateSaltString(),
                Email   = "test",
                Name    = "test",
                PWord   = "1",
                Phone   = "1234",
                Zipcode = "9200"
            };

            userDB.AddUser(u1);

            User expected = client.LoginUser(u1.Email, u1.PWord);

            userDB.RemoveUser(expected.Id);

            Assert.AreEqual(expected.Email, u1.Email);
            Assert.AreEqual(expected.PWord, u1.PWord);
        }
예제 #3
0
        private void btnLogin_Click(object sender, RoutedEventArgs e)
        {
            User user = BikeService.LoginUser(txtUsername.Text, txtPassword.Text);

            if (user != null)
            {
                try
                {
                    BikenBike.CurrentUser = user;
                    window.Content        = new StartPage(window);
                }
                //catch hvis de skriver forkert brugernavn/kode
                catch (Exception exception)
                {
                    Console.WriteLine(exception);
                    throw;
                }
            }
            else
            {
                lblError.Content = "der er sket en fejl";
            }
        }