示例#1
0
        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;
        }
示例#2
0
        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;
        }
示例#3
0
 public static string CurrentUserId(this Microsoft.AspNetCore.Mvc.ControllerBase c)
 {
     return(c.User
            .Claims
            .Where(c => c.Type == AppUserIdClaimType)
            .FirstOrDefault()
            .Value);
 }
示例#4
0
 /// <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));
 }
示例#5
0
 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));
 }
示例#6
0
 /// <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);
 }
示例#8
0
 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);
 }
示例#9
0
 internal static String GetUserID(Microsoft.AspNetCore.Mvc.ControllerBase ctrl)
 {
     return(ctrl.User.FindFirst(ClaimTypes.NameIdentifier)?.Value);
 }