internal static System.Security.Claims.Claim GetScopeClaim(Microsoft.AspNetCore.Mvc.ControllerBase ctrl, String strScope) { var scopeObj = ctrl.User.FindFirst(c => c.Type == strScope); if (scopeObj == null) throw new Exception(); return scopeObj; }
internal static System.Security.Claims.Claim GetUserClaim(Microsoft.AspNetCore.Mvc.ControllerBase ctrl) { var usrObj = ctrl.User.FindFirst(c => c.Type == "sub"); if (usrObj == null) throw new Exception(); return usrObj; }
public static string CurrentUserId(this Microsoft.AspNetCore.Mvc.ControllerBase c) { return(c.User .Claims .Where(c => c.Type == AppUserIdClaimType) .FirstOrDefault() .Value); }
/// <summary> /// Gets the current Audit Scope. /// </summary> /// <param name="controller">The MVC controller.</param> /// <returns>The current Audit Scope or NULL.</returns> public static AuditScope GetCurrentAuditScope(this Microsoft.AspNetCore.Mvc.ControllerBase controller) { return(AuditAttribute.GetCurrentScope(controller.HttpContext)); }
public static int GetLoggedInUserId(Microsoft.AspNetCore.Mvc.ControllerBase controllerBase) { return(int.Parse(controllerBase.User.Claims.First(i => i.Type.Equals(System.Security.Claims.ClaimTypes.Name)).Value)); }
/// <summary> /// Gets the current Audit Scope. /// </summary> /// <param name="apiController">The API controller.</param> /// <returns>The current Audit Scope or NULL.</returns> public static AuditScope GetCurrentAuditScope(this Microsoft.AspNetCore.Mvc.ControllerBase apiController) { return(AuditApiAdapter.GetCurrentScope(apiController.HttpContext)); }
public int GetWeaponOfCurrentUser(Microsoft.AspNetCore.Mvc.ControllerBase controllerBase) { return(GetById(GetLoggedInUserId(controllerBase)).Weapon); }
public static string GetCurrentUser(this Microsoft.AspNetCore.Mvc.ControllerBase controller) { return(controller.User.Claims.First(claim => claim.Type == "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name").Value); }
internal static String GetUserID(Microsoft.AspNetCore.Mvc.ControllerBase ctrl) { return(ctrl.User.FindFirst(ClaimTypes.NameIdentifier)?.Value); }