Created
March 9, 2023 22:42
-
-
Save femakin/da1568853149aaffdec155a9602baa0a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useEffect } from "react"; | |
import { Amplify } from "aws-amplify"; | |
import { withAuthenticator } from "@aws-amplify/ui-react"; | |
import "@aws-amplify/ui-react/styles.css"; | |
import awsconfig from "../../Backend/Backend/aws-exports"; | |
import { useRouter } from "next/navigation"; | |
import { Auth } from "aws-amplify"; | |
Amplify.configure({ ...awsconfig, ssr: true }); | |
function Authaccount({ signOut, user }) { | |
const router = useRouter(); | |
useEffect(() => { | |
Auth.currentAuthenticatedUser({ | |
bypassCache: false, | |
}) | |
.then((result) => { | |
if (user.attributes.locale === "admin") { | |
router.push("/admin"); | |
} else { | |
router.push("/applicant"); | |
} | |
}) | |
.catch((err) => console.log(err)); | |
}, []); | |
} | |
export default withAuthenticator(Authaccount); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment