コード例 #1
0
ファイル: AuthController.cs プロジェクト: TzyHuan/SystemAuth
 public static bool FindToken(this SystemAuthContext context, string Account)
 {
     //用string.Compare區分大小寫判斷帳號密碼
     //若單純用x.Account == Account && x.Password == Password,無法區分大小寫
     return(context.Token.Any(x =>
                              x.Account == Account
                              ));
 }
コード例 #2
0
ファイル: AuthController.cs プロジェクト: TzyHuan/SystemAuth
 public static bool FindUser(this SystemAuthContext context, string Account, string Password)
 {
     //用string.Compare區分大小寫判斷帳號密碼
     //若單純用x.Account == Account && x.Password == Password,無法區分大小寫
     return(context.Member.Any(x =>
                               x.Account == Account &&
                               x.Password == Password
                               ));
 }
コード例 #3
0
 //檢查使用者是否有權限執行該Action
 public static bool HasAllowedAction(this SystemAuthContext context, List <int> userRole, string action)
 {
     return(context.Actions.Any(x =>
                                x.Name == action &&
                                x.IActionRole.Any(
                                    y => userRole.Contains(y.RoleId) && y.ActionId == x.ActionId
                                    )
                                ));
 }
コード例 #4
0
        public static List <int> GetUserRoles(this SystemAuthContext context, string userAccount)
        {
            //預設userRole = 0 (Guest)
            List <int> userRole = new List <int>()
            {
                0
            };

            List <int> RoleID = context.IMemberRole
                                .Where(y => y.Account == userAccount)
                                .Select(x => x.RoleId)
                                .ToList();

            //任一角色有權限即可執行Action
            userRole.AddRange(RoleID);

            return(userRole);
        }
コード例 #5
0
 public IMenuRolesController(SystemAuthContext context)
 {
     _context = context;
 }
コード例 #6
0
 public RoleGroupsController(SystemAuthContext context)
 {
     _context = context;
 }
コード例 #7
0
 public SystemController(IConfiguration config, SystemAuthContext context, IHttpContextAccessor accessor)
 {
     _config   = config;
     _context  = context;
     _accessor = accessor;
 }
コード例 #8
0
 public ActionsController(SystemAuthContext context)
 {
     _context = context;
 }
コード例 #9
0
 public AuthorizationFilter(SystemAuthContext dbContext)
 {
     _context = dbContext;
 }
コード例 #10
0
 public IActionRolesController(SystemAuthContext context)
 {
     _context = context;
 }
コード例 #11
0
 public MembersController(SystemAuthContext context, IHttpContextAccessor accessor)
 {
     _context      = context;
     _accessorUser = accessor.HttpContext?.User?.FindFirst(JwtClaimTypes.Id)?.Value;
 }
コード例 #12
0
 //檢查使用者是否有該角色
 public static bool HasUserRole(this SystemAuthContext context, List <int> userRole, string username)
 {
     return(context.IMemberRole.Any(x => x.Account == username && userRole.Contains(x.RoleId)));
 }
コード例 #13
0
ファイル: MenusController.cs プロジェクト: TzyHuan/SystemAuth
 public MenusController(SystemAuthContext context)
 {
     _context = context;
 }
コード例 #14
0
 public CtrlsController(SystemAuthContext context)
 {
     _context = context;
 }