Exemplo n.º 1
0
        public IActionResult Login(string returnUrl = "")
        {
            var model = new VM_Login {
                ReturnUrl = returnUrl
            };

            return(View(model));
        }
Exemplo n.º 2
0
        public IActionResult Login(string returnUrl = "")
        {
            var model = new VM_Login {
                ReturnUrl = returnUrl
            };

            ViewBag.RegisterMessage = TempData["RegisterMessage"];
            return(View(model));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Login(VM_Login account)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var member = _services.GetUser(account);
                    if (member != null)
                    {
                        var userPrincipal = Helper.GenerateIdentity(member);

                        var props = new AuthenticationProperties
                        {
                            IsPersistent = account.IsRememberMe
                        };

                        //sign in
                        await HttpContext.SignInAsync(
                            scheme : "MyCookieScheme",
                            principal : userPrincipal,
                            properties : props
                            );

                        if (!string.IsNullOrEmpty(account.ReturnUrl) &&
                            Url.IsLocalUrl(account.ReturnUrl))
                        {
                            return(Redirect(account.ReturnUrl));
                        }
                        else
                        {
                            //client
                            if (member.LevelId == 3)
                            {
                                return(RedirectToAction("ClientRealEstateList", "RealEstate"));
                            }
                            return(RedirectToAction("CustomerConfirmList", "RealEstate"));
                        }
                    }
                    else
                    {
                        ViewBag.Message = "Sai tài khoản hoặc mật khẩu!";
                    }
                }
                catch (Exception)
                {
                    throw;
                }
            }
            return(View(account));
        }
 public ActionResult Login(VM_Login admin)
 {
     if (ModelState.IsValid)
     {
         var currentAdmin = _context.Admins
                            .FirstOrDefault(x => x.Username.ToLower() == admin.Username.ToLower() && x.Password == admin.Password);
         if (currentAdmin == null)
         {
             ModelState.AddModelError("", "Username or Password is not correct.");
         }
         else
         {
             return(RedirectToAction("Index", "ManageProduct"));
         }
     }
     return(View("Index"));
 }
Exemplo n.º 5
0
        public async Task <IActionResult> Login(VM_Login account, string returnUrl)
        {
            if (ModelState.IsValid)
            {
                var member = _services.GetUser(account);
                if (member != null)
                {
                    var userPrincipal = Helper.GenerateIdentity(member);

                    var props = new AuthenticationProperties
                    {
                        IsPersistent = account.IsRememberMe
                    };

                    //sign in
                    await HttpContext.SignInAsync(
                        scheme : "MyCookieScheme",
                        principal : userPrincipal,
                        properties : props
                        );

                    if (!string.IsNullOrEmpty(returnUrl) &&
                        Url.IsLocalUrl(returnUrl))
                    {
                        return(Redirect(returnUrl));
                    }
                    else
                    {
                        return(RedirectToAction("Index", "Home"));
                    }
                }
                else
                {
                    ViewBag.ErrorMessage = "Invalid user or password!";
                }
            }
            return(View(account));
        }
Exemplo n.º 6
0
 public OperationResult <LoginInfo> Login(VM_Login obj)
 {
     return(Controller.Login(obj.Username, obj.Password));
 }
Exemplo n.º 7
0
 public Login()
 {
     InitializeComponent();
     login = new VM_Login();
 }
Exemplo n.º 8
0
 public W_Login()
 {
     InitializeComponent();
     base.DataContext = _viewModel = new VM_Login();
     _viewModel.LoginWindowDelegate = LoginWindowsCommand;
 }
Exemplo n.º 9
0
        public Agent GetUser(VM_Login login)
        {
            var user = _dbContext.Agent.SingleOrDefault(x => x.LoginName == login.LoginName && x.Password == login.Password);

            return(user);
        }