Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: consistent login redirects for settings/favorites #14844

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions src/Apps/Settings/settingsRoutes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,6 @@ const DeleteAccountRoute = loadable(
}
)

// Redirect home if the user is not logged in
const handleServerSideRender = ({ req, res }) => {
if (!req.user) {
res.redirect("/")
}
}

export const settingsRoutes: RouteProps[] = [
{
path: "/settings",
Expand All @@ -124,7 +117,6 @@ export const settingsRoutes: RouteProps[] = [
onClientSideRender: () => {
AuctionsRoute.preload()
},
onServerSideRender: handleServerSideRender,
query: graphql`
query settingsRoutes_SettingsAuctionsRouteQuery {
me {
Expand All @@ -139,7 +131,6 @@ export const settingsRoutes: RouteProps[] = [
onClientSideRender: () => {
EditProfileRoute.preload()
},
onServerSideRender: handleServerSideRender,
query: graphql`
query settingsRoutes_EditProfileRouteQuery {
me {
Expand All @@ -154,7 +145,6 @@ export const settingsRoutes: RouteProps[] = [
onClientSideRender: () => {
PaymentsRoute.preload()
},
onServerSideRender: handleServerSideRender,
query: graphql`
query settingsRoutes_PaymentsRouteQuery {
me {
Expand All @@ -169,7 +159,6 @@ export const settingsRoutes: RouteProps[] = [
onClientSideRender: () => {
PurchasesRoute.preload()
},
onServerSideRender: handleServerSideRender,
query: graphql`
query settingsRoutes_PurchasesRouteQuery {
me {
Expand All @@ -190,7 +179,6 @@ export const settingsRoutes: RouteProps[] = [
onClientSideRender: () => {
InsightsRoute.preload()
},
onServerSideRender: handleServerSideRender,
query: graphql`
query settingsRoutes_InsightsRouteQuery {
me {
Expand All @@ -205,7 +193,6 @@ export const settingsRoutes: RouteProps[] = [
onClientSideRender: () => {
EditSettingsRoute.preload()
},
onServerSideRender: handleServerSideRender,
query: graphql`
query settingsRoutes_SettingsEditSettingsRouteQuery {
me {
Expand All @@ -220,7 +207,6 @@ export const settingsRoutes: RouteProps[] = [
onClientSideRender: () => {
DeleteAccountRoute.preload()
},
onServerSideRender: handleServerSideRender,
query: graphql`
query settingsRoutes_DeleteAccountRouteQuery {
me {
Expand All @@ -235,7 +221,6 @@ export const settingsRoutes: RouteProps[] = [
onClientSideRender: () => {
ShippingRoute.preload()
},
onServerSideRender: handleServerSideRender,
query: graphql`
query settingsRoutes_ShippingRouteQuery {
me {
Expand Down
13 changes: 6 additions & 7 deletions src/Server/middleware/userRequiredMiddleware.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import { match } from "path-to-regexp"

const USER_REQUIRED_ROUTES = [
"/auction-result(.*)",
"/favorites/alerts(.*)",
"/favorites/follows(.*)",
"/favorites/saves(.*)",
"/my-collection/artworks(.*)",
"/notifications",
"/orders(.*)",
"/my-collection/artworks(.*)",
"/favorites/alerts(.*)",
"/settings/payments",
"/settings/purchases(.*)",
"/settings/shipping",
"/settings(.*)",
"/user/conversations(.*)",
"/favorites/saves(.*)",
"/auction-result(.*)",
]

const isRequestRequiringUser = req => {
Expand Down