Skip to content
This repository was archived by the owner on Jan 7, 2025. It is now read-only.

Commit 7d5fb00

Browse files
redirecting changes to fix no cookies error
1 parent 5f35a61 commit 7d5fb00

File tree

4 files changed

+20
-4
lines changed

4 files changed

+20
-4
lines changed

apps/backend-serverless/src/models/shopify/process-payment-request.model.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const customerAddressSchema = object().shape({
1212
city: string().required(),
1313
postal_code: string().optional(),
1414
province: string().optional(),
15-
country_code: string().required(),
15+
country_code: string().optional(),
1616
phone_number: string().optional(),
1717
company: string().optional(),
1818
});

apps/merchant-ui/src/components/Welcome.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { SolanaPayMark } from './SolanaPayMark';
55
interface Props {
66
className?: string;
77
isBlocked: string;
8+
isLoggedIn: string;
89
}
910

1011
export function Welcome(props: Props) {
@@ -17,6 +18,12 @@ export function Welcome(props: Props) {
1718
<p className="mt-3 text-neutral-600">
1819
Solana Pay makes it easy for you to accept Solana and USDC payments on your Shopify site.
1920
</p>
21+
{props.isLoggedIn === 'false' && (
22+
<div className="border border-orange-500 bg-orange-50 text-orange-800 rounded-lg p-4 flex flex-row items-center space-x-2 mt-10">
23+
<WarningAlt size={20} />
24+
<p>Please log in to access features</p>
25+
</div>
26+
)}
2027
{props.isBlocked === 'true' ? (
2128
<div className="border border-orange-500 bg-orange-50 text-orange-800 rounded-lg p-4 flex flex-row items-center space-x-2 mt-10">
2229
<WarningAlt size={20} />

apps/merchant-ui/src/middleware.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,19 @@ export function middleware(request: NextRequest) {
6060
}
6161

6262
const isBlocked = isBlockedGeo(request);
63+
const isLoggedIn = request.cookies.has('Bearer') && request.cookies.has('nonce');
6364
const geo = request.geo;
6465

6566
if (geo) {
6667
request.nextUrl.searchParams.set('country', geo.country ?? 'unknown');
6768
}
69+
if (isLoggedIn) {
70+
request.nextUrl.searchParams.set('isLoggedIn', 'false');
71+
}
6872

6973
request.nextUrl.searchParams.set('isBlocked', isBlocked.toString());
7074

71-
if (isBlocked && request.nextUrl.pathname !== '/') {
75+
if ((isBlocked || !isLoggedIn) && request.nextUrl.pathname !== '/') {
7276
request.nextUrl.pathname = '/';
7377
return NextResponse.redirect(request.nextUrl);
7478
}

apps/merchant-ui/src/pages/index.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@ export const getServerSideProps: GetServerSideProps = async (context: GetServerS
1414

1515
export type BlockedProps = {
1616
isBlocked: string;
17+
isLoggedIn: string;
1718
country: string;
1819
};
1920

20-
export default function Home({ isBlocked, country }: BlockedProps) {
21+
export default function Home({ isBlocked, isLoggedIn, country }: BlockedProps) {
2122
return (
2223
<>
2324
<Head>
@@ -29,7 +30,11 @@ export default function Home({ isBlocked, country }: BlockedProps) {
2930
</Head>
3031
<div className={twMerge('grid', 'h-screen', 'w-screen', 'md:grid-cols-2')}>
3132
<div className="flex flex-col justify-center items-center px-6 md:px-24">
32-
<Welcome className="pt-14 md:pt-0 md:mb-56 w-full max-w-md" isBlocked={isBlocked} />
33+
<Welcome
34+
className="pt-14 md:pt-0 md:mb-56 w-full max-w-md"
35+
isBlocked={isBlocked}
36+
isLoggedIn={isLoggedIn}
37+
/>
3338
</div>
3439
<div className={twMerge('relative', 'h-full')}>
3540
<WelcomeHero className={twMerge('absolute', 'inset-0', 'w-full', 'h-full', 'object-cover')} />

0 commit comments

Comments
 (0)