public bool Login(string userId, string pass)
        {
            log.UserID   = userId;
            log.Password = pass;


            if (data.CheckLogin(log) == true)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public async Task <ActionResult <PublicUser> > Login(LoginData data)
        {
            var user = await data.CheckLogin(_context);

            if (user != null)
            {
                await user.Authenticate(HttpContext);

                return(CreatedAtAction(nameof(GetPublicUser), new { user.Username }, new PublicUser()
                {
                    Username = user.Username,
                    RegDate = user.RegDate
                }));
            }

            return(BadRequest("Login or Password are incorrect"));
        }
Exemple #3
0
        public ActionResult Index(LoginModel lg)
        {
            LoginData ld  = new LoginData();
            var       res = ld.CheckLogin(lg.Username, lg.Password);

            if (res == true)
            {
                var student        = ld.GetByTen(lg.Username);
                var studentSession = new ThiSinhInfo();
                studentSession.MaThiSinh = student.MaThiSinh;
                studentSession.HoTen     = student.HoTen;
                studentSession.Image     = student.Image;
                studentSession.MaLop     = student.MaLop;
                Session.Add(CommonConstantsStudent.STUDENT_SESSION, studentSession);
                return(RedirectToAction("Index", "Default", new { area = "Contest" }));
            }
            else
            {
                ModelState.AddModelError("", "Đăng nhập không thành công!");
            }
            return(View(lg));
        }