Skip to content

Commit 15b8a81

Browse files
committed
fix: redirect stats page to login user
1 parent 2e274bd commit 15b8a81

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/pages/stats/[login].tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useState } from "react";
1+
import { useEffect, useState } from "react";
22
import { useSession } from "next-auth/react";
33
import { useRouter } from "next/router";
44
import { useGitHubPullRequests, useHandleStateRepositories } from "@/hooks";
@@ -38,6 +38,12 @@ export default function Stats() {
3838
repositoriesOrder
3939
);
4040

41+
useEffect(() => {
42+
if (session && session.user && session.user.login !== login) {
43+
router.replace(`/stats/${session.user.login}`);
44+
}
45+
}, [session, login, router]);
46+
4147
return (
4248
<div className="h-full w-full px-4 flex flex-col gap-4">
4349
<div className="mt-4">

0 commit comments

Comments
 (0)