Exemplo n.º 1
0
        public async Task <IActionResult> Login(OpenIdConnectRequest request)
        {
            var user = await _userManager.FindByEmailAsync(request.Username);

            if (user == null)
            {
                return(BadRequest(CommonResponse.Fail("Invalid username or password")));
            }

            var result = await _signInManager.CheckPasswordSignInAsync(user, request.Password, false);

            if (!result.Succeeded)
            {
                return(BadRequest(CommonResponse.Fail("Invalid username or password")));
            }

            var ticket = await _ticketHelper.CreateTicketAsync(request, user);

            return(SignIn(ticket.Principal, ticket.Properties, ticket.AuthenticationScheme));
        }