コード例 #1
0
        public void CheckLogin()
        {
            User _testNotExistingUser = new User
            {
                UserId      = 1,
                UserEmail   = "*****@*****.**",
                Password    = "******",
                FirstName   = "Davey",
                LastName    = "Cornelissen",
                BirthDay    = DateTime.Now,
                PhoneNumber = "0628433115",
                PpPath      = "/Test/Profile.PNG"
            };

            _accountLogic.CheckLogin(_testNotExistingUser.UserEmail, _testNotExistingUser.Password);
        }
コード例 #2
0
ファイル: AccountController.cs プロジェクト: Bartske/ShoeShop
        public IActionResult Login(Login login)
        {
            if (!ModelState.IsValid)
            {
                return(View("Login", login));
            }

            login = AccountLogic.CheckLogin(login);
            Account account = AccountLogic.GetAccount(login.ID);

            if (account.MiddleName == null)
            {
                HttpContext.Session.SetString("FullName", account.FirstName + " " + account.LastName);
            }
            else
            {
                HttpContext.Session.SetString("FullName", account.FirstName + " " + account.MiddleName + " " + account.LastName);
            }

            HttpContext.Session.SetString("AccountID", account.ID.ToString());

            if (account.Admin)
            {
                return(RedirectToAction("Index", "Manage"));
            }
            else
            {
                return(RedirectToAction("Index", "Home"));
            }
        }
コード例 #3
0
ファイル: UnitTest1.cs プロジェクト: Lvdzandt/Webshop-S2
        public void CheckLoginTest()
        {
            //arrange
            IAccountContext context  = new TestDateContext();
            AccountLogic    logic    = new AccountLogic();
            string          email    = "*****@*****.**";
            string          password = "******";

            //act
            bool checklogin = logic.CheckLogin(context, email, password);

            //assert
            Assert.IsTrue(checklogin);
        }
コード例 #4
0
 public IActionResult Login(LoginViewModel model)
 {
     if (_accountLogic.CheckLogin(model.Email, model.Password))
     {
         HttpContext.Session.SetString(SessionKeyName, model.Email);
         Account account = _accountLogic.GetUser(model.Email);
         if (account.IsAdmin)
         {
             HttpContext.Session.SetString(SessionKeyIsAdmin, "1");
             return(RedirectToAction("Index", "Home"));
         }
         return(RedirectToAction("Index", "Home"));
     }
     ModelState.AddModelError("", "Username or Password was incorrect");
     return(View(model));
 }
コード例 #5
0
        public async Task <IActionResult> Login(LoginViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            try
            {
                //check if the user input is valid
                _accountLogic.CheckLogin(model.Email, model.Password);
                //Get the cookie info
                User cookieInfo = _accountLogic.GetCookieInfo(model.Email);

                CookieCreate cookieCreate = new CookieCreate();
                cookieCreate.addClaims("Id", cookieInfo.UserId.ToString());
                cookieCreate.addClaims("UserName", cookieInfo.FirstName);
                cookieCreate.addClaims("UserPicture", cookieInfo.PpPath);
                var claimsPrincipal = cookieCreate.CreateCookieAuth("FishCookies");

                //to login the user
                await HttpContext.SignInAsync(
                    "FishCookies", claimsPrincipal,
                    new AuthenticationProperties
                {
                    IsPersistent = model.Remember
                });

                return(RedirectToAction("TimeLine", "Timeline"));
            }
            catch (ExceptionHandler exception)
            {
                ViewData[exception.Index] = exception.Message;
                return(View());
            }
        }