Skip to content

Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.

776 B
Raw Blame
"use client";
import { Button } from "@rallly/ui/button";

import { LastUsedBadge } from "@/features/auth/components/last-used-badge";
import { authClient } from "@/lib/auth-client";
import { validateRedirectUrl } from "@/lib/utils/redirect";

export function LoginWithOIDC({
  name,
  redirectTo,
  isLastUsed,
}: {
  name: string;
  redirectTo?: string;
  isLastUsed?: boolean;
}) {
  return (
    <Button
      onClick={() => {
        authClient.signIn.oauth2({
          providerId: "oidc",
          callbackURL: validateRedirectUrl(redirectTo) || "/",
          errorCallbackURL: "/login",
        });
      }}
      className="relative w-full"
      size="xl"
      shape="rounded"
    >
      {name}
      {isLastUsed ? <LastUsedBadge /> : null}
    </Button>
  );
}