Example #1
0
        public async Task <IActionResult> Login([FromBody] LoginCredentials creds)
        {
            await InitAuth(creds);

            if (!await ValidateLogin(creds))
            {
                return(Json(new
                {
                    error = "Login failed"
                }));
            }

            var principal = await GetPrincipal(creds, Startup.CookieAuthScheme);

            await HttpContext.SignInAsync(Startup.CookieAuthScheme, principal);

            var response = LoginResponse.CreateFromPrincipal(principal);

            return(response.AsJsonResponse());
        }