예제 #1
0
        public IActionResult Login([HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "auth/login")] AuthLoginRequestContract contract)
        {
            if (string.IsNullOrEmpty(contract.BadgeCode) || string.IsNullOrEmpty(contract.AgentId))
            {
                return(new BadRequestResult());
            }

            var id = _authService.Login(contract.AgentId, contract.BadgeCode);

            if (id.HasValue)
            {
                var jwtResult = AccessTokenProvider.GenerateToken(id.ToString());
                return(new OkObjectResult(jwtResult));
            }

            return(new BadRequestObjectResult(new BadRequestResponseContract()
            {
                Message = "Invalid Username or password."
            }));
        }