Skip to content

Commit

Permalink
fix: redirect stats page to login user
Browse files Browse the repository at this point in the history
  • Loading branch information
DomeT99 committed Jan 15, 2025
1 parent 2e274bd commit 15b8a81
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/pages/stats/[login].tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState } from "react";
import { useEffect, useState } from "react";
import { useSession } from "next-auth/react";
import { useRouter } from "next/router";
import { useGitHubPullRequests, useHandleStateRepositories } from "@/hooks";
Expand Down Expand Up @@ -38,6 +38,12 @@ export default function Stats() {
repositoriesOrder
);

useEffect(() => {
if (session && session.user && session.user.login !== login) {
router.replace(`/stats/${session.user.login}`);
}
}, [session, login, router]);

return (
<div className="h-full w-full px-4 flex flex-col gap-4">
<div className="mt-4">
Expand Down

0 comments on commit 15b8a81

Please sign in to comment.