Esempio n. 1
0
        public async Task <IActionResult> Login([FromQuery] LoginRequestModel model)
        {
            var serviceResult = await _userService.Login(model);

            if (serviceResult.ServiceResultType == ServiceResultType.Fail)
            {
                return(BadRequest(serviceResult.ErrorModel));
            }

            var token = JwtUtil.CreateJwtToken(serviceResult.Data);

            return(Ok(new
            {
                user = serviceResult.Data,
                token = new JwtSecurityTokenHandler().WriteToken(token),
                expiration = token.ValidTo
            }));
        }