import { AbilityBuilder, createMongoAbility } from "@casl/ability";

export function defineAbilitiesFor(user) {
  const { can, cannot, build } = new AbilityBuilder(createMongoAbility);

  if (user) {
    can("access", "Dashboard");
    cannot("access", "Login");
  } else {
    can("access", "Login");
    cannot("access", "Dashboard");
  }

  return build();
}
