Пример #1
0
 public IActionResult AuthorizeUser(Principal principal)
 {
     if (AuthorizationHelper.ValidatePrincipal(principal, "user"))
     {
         var tokenString = AuthorizationHelper.GenerateJWT(principal, "user");
         logger.Log(LogLevel.Warning, $"requestId: {Request.HttpContext.TraceIdentifier}, previousRequestId:No previous ID, Message: User {principal.Username} succesfully logged in");
         return(Ok(new { token = tokenString }));
     }
     logger.Log(LogLevel.Warning, $"requestId: {Request.HttpContext.TraceIdentifier}, previousRequestID:No previous ID, Message: Invalid credentials from client");
     return(Unauthorized());
 }