Skip to content

Commit cfb59e2

Browse files
committed
Fix google auth redirect
1 parent 1aa526a commit cfb59e2

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

app/login/page.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Grid, Typography } from "@mui/material";
33
import GoogleIcon from "@mui/icons-material/Google";
44
import * as z from "zod";
55
import { signIn } from "next-auth/react";
6-
import { useRouter } from "next/navigation";
6+
import { useRouter, useSearchParams } from "next/navigation";
77
import Link from "next/link";
88
import { useState } from "react";
99
import { Button, Form, TextInput } from "@/components";
@@ -22,6 +22,8 @@ const Login = () => {
2222
const [isLoading, setIsLoading] = useState(false);
2323
const { replace, refresh } = useRouter();
2424
const { enqueueSnackbar } = useSnackbar();
25+
const searchParams = useSearchParams();
26+
const callbackUrl = searchParams.get("callbackUrl") || "/";
2527

2628
const onSubmit = async (data: FieldValues) => {
2729
setIsLoading(true);
@@ -76,7 +78,7 @@ const Login = () => {
7678
size="large"
7779
fullWidth
7880
variant="contained"
79-
onClick={() => signIn("google")}
81+
onClick={() => signIn("google", { callbackUrl })}
8082
startIcon={<GoogleIcon />}
8183
>
8284
Sign in with google

components/code-items/CodeItem.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ export const CodeItem = ({ codeItemName, codeItemId }: CodeItemProps) => {
7373
sx={{
7474
all: "unset",
7575
borderRadius: "50%",
76+
height: 28,
77+
width: 28,
7678
}}
7779
>
7880
<Delete

middleware.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export { default } from "next-auth/middleware";
22

33
export const config = {
4-
matcher: ["/"],
4+
matcher: ["/", "/code-items/:path*"],
55
};

0 commit comments

Comments
 (0)