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 )); }
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 )); }
//檢查使用者是否有權限執行該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 ) )); }
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); }
public IMenuRolesController(SystemAuthContext context) { _context = context; }
public RoleGroupsController(SystemAuthContext context) { _context = context; }
public SystemController(IConfiguration config, SystemAuthContext context, IHttpContextAccessor accessor) { _config = config; _context = context; _accessor = accessor; }
public ActionsController(SystemAuthContext context) { _context = context; }
public AuthorizationFilter(SystemAuthContext dbContext) { _context = dbContext; }
public IActionRolesController(SystemAuthContext context) { _context = context; }
public MembersController(SystemAuthContext context, IHttpContextAccessor accessor) { _context = context; _accessorUser = accessor.HttpContext?.User?.FindFirst(JwtClaimTypes.Id)?.Value; }
//檢查使用者是否有該角色 public static bool HasUserRole(this SystemAuthContext context, List <int> userRole, string username) { return(context.IMemberRole.Any(x => x.Account == username && userRole.Contains(x.RoleId))); }
public MenusController(SystemAuthContext context) { _context = context; }
public CtrlsController(SystemAuthContext context) { _context = context; }