Exemplo n.º 1
0
        // [ProducesResponseType(409, Type = typeof(ClientErrorResponse))]
        public async Task <IActionResult> SignIn(SignInModel model)
        {
            var user = await userManager.FindByNameAsync(model.Username) ?? await userManager.FindByEmailAsync(model.Username);

            if (user != null)
            {
                var result = await signInManager.CheckPasswordSignInAsync(user, model.Password, lockoutOnFailure : false);

                if (result.Succeeded)
                {
                    return(Ok(await accessTokenProvider.CreateAccessTokenAsync(user)));
                }
            }

            return(this.Error("E_INVALID_CREDENTIALS", "Invalid username or password"));
        }