Skip to content

Instantly share code, notes, and snippets.

@femakin
Created March 9, 2023 22:42
Show Gist options
  • Save femakin/da1568853149aaffdec155a9602baa0a to your computer and use it in GitHub Desktop.
Save femakin/da1568853149aaffdec155a9602baa0a to your computer and use it in GitHub Desktop.
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