Ejemplo n.º 1
0
        public IHttpActionResult Post(AuthenticateInputModel model)
        {
            if (model == null)
            {
                return(BadRequest("The request cannot be null"));
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest("Invalid Request"));
            }
            var user = _userManager.Find(model.Username, model.Password);

            if (user == null)
            {
                return(Unauthorized());
            }
            var jwtToken = _tokenGenerator.GenerateFor(user.UserName);

            // get current project
            // look up will be based on the current project
            return(Ok(new AuthenticationOutputModel
            {
                Id = user.Id,
                Name = user.UserName,
                JWTToken = jwtToken,
            }));
        }