Пример #1
0
 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
 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
 public MenusController(SystemAuthContext context)
 {
     _context = context;
 }
Пример #14
0
 public CtrlsController(SystemAuthContext context)
 {
     _context = context;
 }