init
This commit is contained in:
commit
e124a47765
19374 changed files with 9806149 additions and 0 deletions
43
KretaWeb/Logger/RequestUserRenderer.cs
Normal file
43
KretaWeb/Logger/RequestUserRenderer.cs
Normal file
|
@ -0,0 +1,43 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Kreta.Web.Logging.Logger;
|
||||
using Kreta.Web.Security;
|
||||
|
||||
namespace Kreta.Web.Logger
|
||||
{
|
||||
/// <summary>
|
||||
/// Logging field renderer
|
||||
/// </summary>
|
||||
class RequestUserRenderer : LoggingFieldRenderer
|
||||
{
|
||||
/// <summary>
|
||||
/// Render
|
||||
/// </summary>
|
||||
/// <param name="fieldName">Field</param>
|
||||
/// <param name="context">Context</param>
|
||||
public override void Render(string fieldName, LoggingFieldRendererContext context)
|
||||
{
|
||||
if (string.Compare(RequestResponseLoggingFields.Request.User, fieldName, StringComparison.OrdinalIgnoreCase) != 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
string user = context.GetFieldValue(fieldName) as string;
|
||||
if (!string.IsNullOrWhiteSpace(user))
|
||||
{
|
||||
try
|
||||
{
|
||||
List<string> roles = ClaimData.FelhasznaloSzerepCsomagok;
|
||||
if (roles != null && roles.Count > 0)
|
||||
{
|
||||
context.SetFieldValue(fieldName, $"{user}/[{string.Join(",", roles)}]");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
context.SetFieldValue(fieldName, ex.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue