Show 'Go to App' button for authenticated users on landing page
Instead of displaying sign-in buttons to already authenticated users, the homepage now detects authentication status and shows a 'Go to App' button that redirects to the home page. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,13 +1,14 @@
|
||||
import { FC, ReactNode } from 'react';
|
||||
import { Main } from '@/app/ui/Main';
|
||||
|
||||
import { authConfig } from "@/app/lib/auth";
|
||||
import { authConfig, myAuth } from "@/app/lib/auth";
|
||||
import { SignInButton } from '@/app/ui/SignInButton';
|
||||
import Image from 'next/image';
|
||||
import { getTranslations } from "next-intl/server";
|
||||
import { getTranslations, getLocale } from "next-intl/server";
|
||||
import isWebview from "is-ua-webview";
|
||||
import { headers } from 'next/headers'
|
||||
import { headers } from 'next/headers';
|
||||
import { ExclamationTriangleIcon } from "@heroicons/react/24/outline";
|
||||
import Link from 'next/link';
|
||||
|
||||
type Provider = {
|
||||
id: string;
|
||||
@@ -38,6 +39,8 @@ function getKeyValuesFromObject<T>(obj: any, keys: (keyof T)[]): T {
|
||||
|
||||
const Page:FC = async () => {
|
||||
|
||||
const session = await myAuth();
|
||||
const locale = await getLocale();
|
||||
const providers = await getProviders();
|
||||
const t = await getTranslations("login-page");
|
||||
// get userAgent from NextJS
|
||||
@@ -76,11 +79,21 @@ const Page:FC = async () => {
|
||||
}
|
||||
<span className="flex justify-center">
|
||||
{
|
||||
Object.values(providers).map((provider) => (
|
||||
<div key={provider.name}>
|
||||
<SignInButton provider={provider} />
|
||||
</div>
|
||||
))
|
||||
session ? (
|
||||
<Link
|
||||
href={`/${locale}/home`}
|
||||
className="btn btn-neutral btn-lg"
|
||||
>
|
||||
<Image src="/icon2.png" alt="logo" width={32} height={32} />
|
||||
{t("main-card.go-to-app")}
|
||||
</Link>
|
||||
) : (
|
||||
Object.values(providers).map((provider) => (
|
||||
<div key={provider.name}>
|
||||
<SignInButton provider={provider} />
|
||||
</div>
|
||||
))
|
||||
)
|
||||
}
|
||||
</span>
|
||||
<video className="m-auto mt-4" title={t("main-card.video-title")} role="img" data-js-id="hero" loop muted playsInline autoPlay poster={t("main-card.image-url")}>
|
||||
|
||||
Reference in New Issue
Block a user