コード例 #1
0
        public async Task <IActionResult> Login([FromBody] LoginViewModel model)
        {
            _log4net.Info("Authentication initiated");
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }


            var RightUser = await loginRepo.GetAccount(model);

            if (RightUser == null)
            {
                //ModelState.AddModelError("", "Invalid Username or Password");
                return(NotFound());
            }
            else
            {
                _log4net.Info("Login credential matched");
                return(Ok(new
                {
                    token = GenerateJWT(RightUser)
                }));
            }
        }