예제 #1
0
        public async Task <IActionResult> Login([FromBody] LoginInformation loginInformation)
        {
            var authenticationResult = await authenticationModule.AuthenticateAsync(loginInformation);

            if (authenticationResult.IsAuthenticated)
            {
                apiEventLogger.Log(LogLevel.Info, $"User '{loginInformation.Username}' successfully logged in");
            }
            else
            {
                apiEventLogger.Log(LogLevel.Warning, $"User '{loginInformation.Username}' was rejected");
            }
            return(new ContentResult
            {
                ContentType = Conventions.JsonContentType,
                Content = JsonConvert.SerializeObject(authenticationResult),
                StatusCode = authenticationResult.IsAuthenticated ? (int)HttpStatusCode.OK : (int)HttpStatusCode.Unauthorized
            });
        }