INNER CODE UNIT · TypeScript

matchesFilter

aws-devtools-labs/aws-blocks · packages/bb-auth-cognito/src/index.ts:330

		const matchesFilter = (user: AdminUser, filter?: AdminUserFilter): boolean => {
			if (!filter) return true;
			const candidate =
				filter.attribute === 'username' ? user.username
				: filter.attribute === 'status' ? (user.enabled ? 'Enabled' : 'Disabled')
				: (user.attributes as Record<string, string>)[filter.attribute];
			if (candidate == null) return false;
			return filter.match === 'startsWith' ? candidate.startsWith(filter.value) : candidate === filter.value;
		};

		return {
			// ── GroupAdmin ───────────────────────────────────────────────────
			addUserToGroup: async (username, group) => {
				this.assertAdminAction('groups');
				requireUser(username);
				const members = requireGroup(group);
				if (!members.includes(username)) members.push(username);
				this.flushToDisk();

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…