feat: add linuxdo oauth
This commit is contained in:
@@ -5,6 +5,31 @@ import Resend from "next-auth/providers/resend";
|
||||
|
||||
import { env } from "@/env.mjs";
|
||||
|
||||
const linuxDoProvider: any = {
|
||||
id: "linuxdo",
|
||||
name: "Linux Do",
|
||||
version: "1.0",
|
||||
type: "oauth",
|
||||
authorization: "https://connect.linux.do/oauth2/authorize",
|
||||
token: "https://connect.linux.do/oauth2/token",
|
||||
userinfo: "https://connect.linux.do/api/user",
|
||||
clientId: env.LinuxDo_CLIENT_ID,
|
||||
clientSecret: env.LinuxDo_CLIENT_SECRET,
|
||||
checks: ["state"],
|
||||
profile: (profile: any) => {
|
||||
// console.log("profile", profile);
|
||||
return {
|
||||
id: profile.user.id.toString(),
|
||||
username: profile.user.username,
|
||||
name: profile.user.username,
|
||||
active: profile.user.active,
|
||||
trust_level: profile.user.trust_level,
|
||||
silenced: profile.user.silenced,
|
||||
email: profile.user.email,
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
export default {
|
||||
providers: [
|
||||
Google({
|
||||
@@ -19,5 +44,6 @@ export default {
|
||||
apiKey: env.RESEND_API_KEY,
|
||||
from: "wrdo <support@wr.do>",
|
||||
}),
|
||||
linuxDoProvider,
|
||||
],
|
||||
} satisfies NextAuthConfig;
|
||||
|
||||
@@ -33,6 +33,8 @@ export function UserAuthForm({ className, type, ...props }: UserAuthFormProps) {
|
||||
const [isLoading, setIsLoading] = React.useState<boolean>(false);
|
||||
const [isGoogleLoading, setIsGoogleLoading] = React.useState<boolean>(false);
|
||||
const [isGithubLoading, setIsGithubLoading] = React.useState<boolean>(false);
|
||||
const [isLinuxDoLoading, setIsLinuxDoLoading] =
|
||||
React.useState<boolean>(false);
|
||||
const searchParams = useSearchParams();
|
||||
|
||||
async function onSubmit(data: FormData) {
|
||||
@@ -70,7 +72,8 @@ export function UserAuthForm({ className, type, ...props }: UserAuthFormProps) {
|
||||
!siteConfig.openSignup ||
|
||||
isLoading ||
|
||||
isGoogleLoading ||
|
||||
isGithubLoading
|
||||
isGithubLoading ||
|
||||
isLinuxDoLoading
|
||||
}
|
||||
>
|
||||
{isGoogleLoading ? (
|
||||
@@ -91,7 +94,8 @@ export function UserAuthForm({ className, type, ...props }: UserAuthFormProps) {
|
||||
!siteConfig.openSignup ||
|
||||
isLoading ||
|
||||
isGithubLoading ||
|
||||
isGoogleLoading
|
||||
isGoogleLoading ||
|
||||
isLinuxDoLoading
|
||||
}
|
||||
>
|
||||
{isGithubLoading ? (
|
||||
@@ -101,6 +105,28 @@ export function UserAuthForm({ className, type, ...props }: UserAuthFormProps) {
|
||||
)}{" "}
|
||||
Github
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className={cn(buttonVariants({ variant: "outline" }))}
|
||||
onClick={() => {
|
||||
setIsLinuxDoLoading(true);
|
||||
signIn("linuxdo");
|
||||
}}
|
||||
disabled={
|
||||
!siteConfig.openSignup ||
|
||||
isLoading ||
|
||||
isGithubLoading ||
|
||||
isGoogleLoading ||
|
||||
isLinuxDoLoading
|
||||
}
|
||||
>
|
||||
{isLinuxDoLoading ? (
|
||||
<Icons.spinner className="mr-2 size-4 animate-spin" />
|
||||
) : (
|
||||
<img src="/_static/images/linuxdo.webp" className="mr-2 size-4" />
|
||||
)}{" "}
|
||||
LinuxDo
|
||||
</button>
|
||||
|
||||
<div className="relative my-3">
|
||||
<div className="absolute inset-0 flex items-center">
|
||||
|
||||
@@ -3,6 +3,7 @@ import Image from "next/image";
|
||||
import Link from "next/link";
|
||||
|
||||
import { siteConfig } from "@/config/site";
|
||||
import { getCurrentUser } from "@/lib/session";
|
||||
import { cn, nFormatter } from "@/lib/utils";
|
||||
import { buttonVariants } from "@/components/ui/button";
|
||||
import { Icons } from "@/components/shared/icons";
|
||||
@@ -10,6 +11,7 @@ import { Icons } from "@/components/shared/icons";
|
||||
import GitHubStarsWithSuspense from "../shared/github-star-wrapper";
|
||||
|
||||
export default async function HeroLanding() {
|
||||
const user = await getCurrentUser();
|
||||
return (
|
||||
<section className="space-y-6 py-12 sm:py-20 lg:py-24">
|
||||
<div className="container flex max-w-screen-md flex-col items-center gap-5 text-center">
|
||||
@@ -53,7 +55,7 @@ export default async function HeroLanding() {
|
||||
"gap-2 px-5 text-[15px] font-semibold",
|
||||
)}
|
||||
>
|
||||
<span>Sign in for free</span>
|
||||
<span>{user?.id ? "Dashboard" : "Sign in for free"}</span>
|
||||
<Icons.arrowRight className="size-4" />
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
@@ -11,6 +11,8 @@ export const env = createEnv({
|
||||
GOOGLE_CLIENT_SECRET: z.string().min(1),
|
||||
GITHUB_ID: z.string().min(1),
|
||||
GITHUB_SECRET: z.string().min(1),
|
||||
LinuxDo_CLIENT_ID: z.string().min(1),
|
||||
LinuxDo_CLIENT_SECRET: z.string().min(1),
|
||||
DATABASE_URL: z.string().min(1),
|
||||
RESEND_API_KEY: z.string().min(1),
|
||||
CLOUDFLARE_ZONE_ID: z.string().min(1),
|
||||
@@ -43,5 +45,7 @@ export const env = createEnv({
|
||||
CLOUDFLARE_EMAIL: process.env.CLOUDFLARE_EMAIL,
|
||||
SCREENSHOTONE_BASE_URL: process.env.SCREENSHOTONE_BASE_URL,
|
||||
GITHUB_TOKEN: process.env.GITHUB_TOKEN,
|
||||
LinuxDo_CLIENT_ID: process.env.LinuxDo_CLIENT_ID,
|
||||
LinuxDo_CLIENT_SECRET: process.env.LinuxDo_CLIENT_SECRET,
|
||||
},
|
||||
});
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 622 B |
Reference in New Issue
Block a user