@@ -58,5 +45,3 @@ const Home = (props: { hotContracts: Contract[] }) => {
)
}
-
-export default Home
diff --git a/web/pages/links.tsx b/web/pages/links.tsx
index 76c62978..490f1878 100644
--- a/web/pages/links.tsx
+++ b/web/pages/links.tsx
@@ -18,11 +18,14 @@ import { Avatar } from 'web/components/avatar'
import { RelativeTimestamp } from 'web/components/relative-timestamp'
import { UserLink } from 'web/components/user-page'
import { CreateLinksButton } from 'web/components/manalinks/create-links-button'
+import { redirectIfLoggedOut } from 'web/lib/firebase/server-auth'
import dayjs from 'dayjs'
import customParseFormat from 'dayjs/plugin/customParseFormat'
dayjs.extend(customParseFormat)
+export const getServerSideProps = redirectIfLoggedOut('/')
+
export function getManalinkUrl(slug: string) {
return `${location.protocol}//${location.host}/link/${slug}`
}
diff --git a/web/pages/profile.tsx b/web/pages/profile.tsx
index b80698ae..541f5de9 100644
--- a/web/pages/profile.tsx
+++ b/web/pages/profile.tsx
@@ -1,6 +1,5 @@
import React, { useEffect, useState } from 'react'
import { RefreshIcon } from '@heroicons/react/outline'
-import Router from 'next/router'
import { AddFundsButton } from 'web/components/add-funds-button'
import { Page } from 'web/components/page'
@@ -18,6 +17,9 @@ import { updateUser, updatePrivateUser } from 'web/lib/firebase/users'
import { defaultBannerUrl } from 'web/components/user-page'
import { SiteLink } from 'web/components/site-link'
import Textarea from 'react-expanding-textarea'
+import { redirectIfLoggedOut } from 'web/lib/firebase/server-auth'
+
+export const getServerSideProps = redirectIfLoggedOut('/')
function EditUserField(props: {
user: User
@@ -134,8 +136,7 @@ export default function ProfilePage() {
})
}
- if (user === null) {
- Router.replace('/')
+ if (user == null) {
return <>>
}
diff --git a/web/pages/trades.tsx b/web/pages/trades.tsx
index 55a08bc6..a29fb7f0 100644
--- a/web/pages/trades.tsx
+++ b/web/pages/trades.tsx
@@ -1,17 +1,10 @@
import Router from 'next/router'
-import { useEffect } from 'react'
+import { redirectIfLoggedOut } from 'web/lib/firebase/server-auth'
-import { useUser } from 'web/hooks/use-user'
+export const getServerSideProps = redirectIfLoggedOut('/')
// Deprecated: redirects to /portfolio.
// Eventually, this will be removed.
export default function TradesPage() {
- const user = useUser()
-
- useEffect(() => {
- if (user === null) Router.replace('/')
- else Router.replace('/portfolio')
- })
-
- return <>>
+ Router.replace('/portfolio')
}