feat/valid-session: check valid user/session from token instead of making a slow request to api
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { getName } from "@/lib/trpc/memoizedRequests"
|
||||
|
||||
import { auth } from "@/auth"
|
||||
import ArrowRight from "@/components/Icons/ArrowRight"
|
||||
import { ScandicFriends } from "@/components/Levels"
|
||||
import LoginButton from "@/components/LoginButton"
|
||||
@@ -8,6 +9,7 @@ import Link from "@/components/TempDesignSystem/Link"
|
||||
import Body from "@/components/TempDesignSystem/Text/Body"
|
||||
import Title from "@/components/TempDesignSystem/Text/Title"
|
||||
import { getIntl } from "@/i18n"
|
||||
import { isValidSession } from "@/utils/session"
|
||||
|
||||
import Contact from "./Contact"
|
||||
import ReadMore from "./ReadMore"
|
||||
@@ -19,10 +21,10 @@ import type { JoinLoyaltyContactProps } from "@/types/components/sidebar/joinLoy
|
||||
export default async function JoinLoyaltyContact({
|
||||
block,
|
||||
}: JoinLoyaltyContactProps) {
|
||||
const [intl, user] = await Promise.all([getIntl(), getName()])
|
||||
const [intl, session] = await Promise.all([getIntl(), auth()])
|
||||
|
||||
// Check if we have user, that means we are logged in.
|
||||
if (user) {
|
||||
// Check if we valid session, that means we are logged in.
|
||||
if (isValidSession(session)) {
|
||||
return null
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user