Next.js template
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.js 640B

12345678910111213141516171819202122232425262728
  1. import { getSession, useSession } from 'next-auth/react';
  2. import ProfileCard from '../../components/cards/profile-card/ProfileCard';
  3. import { LOGIN_PAGE } from '../../constants/pages';
  4. const ProfilePage = () => {
  5. const { data: session } = useSession();
  6. return <ProfileCard profileData={{ name: session.user.name }} />;
  7. };
  8. export async function getServerSideProps(context) {
  9. const session = await getSession({ req: context.req });
  10. if (!session) {
  11. return {
  12. redirect: {
  13. destination: LOGIN_PAGE,
  14. permanent: false,
  15. },
  16. };
  17. }
  18. return {
  19. props: { session },
  20. };
  21. }
  22. export default ProfilePage;