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: #2579 unprotect routes #2605

Merged
merged 2 commits into from
Sep 8, 2020
Merged
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
1 change: 1 addition & 0 deletions packages/developer-portal/src/components/ui/menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export type MenuProps = {}
export const Menu: React.FunctionComponent<MenuProps> = () => {
const location = useLocation()
const menuConfigs = generateMenuConfig(location)
if (location.pathname === Routes.INVITE) return null
return <Sidebar {...menuConfigs} location={location} />
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,17 @@ exports[`Router should match a snapshot 1`] = `
path="/404"
render={[Function]}
/>
<Component
path="/invite"
showMenu={false}
>
<Component
component={
Object {
"$$typeof": Symbol(react.lazy),
"_ctor": [Function],
"_result": null,
"_status": -1,
}
<Route
component={
Object {
"$$typeof": Symbol(react.lazy),
"_ctor": [Function],
"_result": null,
"_status": -1,
}
path="/"
/>
</Component>
}
path="/invite"
/>
<Component
path="/"
>
Expand Down
5 changes: 1 addition & 4 deletions packages/developer-portal/src/core/router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,7 @@ const Router = () => {
<Route path={Routes.REGISTER} render={() => <Register />} />
<Route path={Routes.REGISTER_CONFIRM} exact component={RegisterConfirm} />
<Route path={Routes.FOUR_O_FOUR} exact render={() => <Info infoType="404" />} />

<PrivateRouteWrapper path={Routes.INVITE} showMenu={false}>
<PrivateRoute path="/" component={Invite} />
</PrivateRouteWrapper>
<Route path={Routes.INVITE} component={Invite} />

<PrivateRouteWrapper path="/">
<Switch>
Expand Down
32 changes: 28 additions & 4 deletions packages/developer-portal/src/services/developers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,13 @@ export const fetchDeveloperById = async (params: FetchDeveloperByIdParams): Prom
url: `${URLS.developers}/${id}`,
api: window.reapit.config.marketplaceApiUrl,
method: 'GET',
headers: await generateHeader(window.reapit.config.marketplaceApiKey),
headers:
// Route is unprotected in prod so users can accept invites. In dev, it is protected by the API key still
window.reapit.config.appEnv === 'production'
? {
'Content-Type': 'application/json',
}
: await generateHeader(window.reapit.config.marketplaceApiKey),
})
return response
} catch (error) {
Expand Down Expand Up @@ -168,7 +174,13 @@ export const fetchMemberDetails = async (params: FetchMemberDetailsParams): Prom
url: `${URLS.developers}/${developerId}/members/${memberId}`,
api: window.reapit.config.marketplaceApiUrl,
method: 'GET',
headers: await generateHeader(window.reapit.config.marketplaceApiKey),
headers:
// Route is unprotected in prod so users can accept invites. In dev, it is protected by the API key still
window.reapit.config.appEnv === 'production'
? {
'Content-Type': 'application/json',
}
: await generateHeader(window.reapit.config.marketplaceApiKey),
})
return response
} catch (error) {
Expand All @@ -185,7 +197,13 @@ export const acceptInviteMember = async (params: AcceptInviteMemberParams) => {
api: window.reapit.config.marketplaceApiUrl,
method: 'POST',
body: restParams,
headers: await generateHeader(window.reapit.config.marketplaceApiKey),
headers:
// Route is unprotected in prod so users can accept invites. In dev, it is protected by the API key still
window.reapit.config.appEnv === 'production'
? {
'Content-Type': 'application/json',
}
: await generateHeader(window.reapit.config.marketplaceApiKey),
})
return response
} catch (error) {
Expand All @@ -201,7 +219,13 @@ export const rejectInviteMember = async (params: RejectInviteMemberParams) => {
url: `${URLS.developers}/${developerId}/members/${memberId}/reject`,
api: window.reapit.config.marketplaceApiUrl,
method: 'POST',
headers: await generateHeader(window.reapit.config.marketplaceApiKey),
headers:
// Route is unprotected in prod so users can accept invites. In dev, it is protected by the API key still
window.reapit.config.appEnv === 'production'
? {
'Content-Type': 'application/json',
}
: await generateHeader(window.reapit.config.marketplaceApiKey),
})
return response
} catch (error) {
Expand Down
9 changes: 0 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5274,15 +5274,6 @@
jsonwebtoken "^8.5.1"
snyk "^1.335.0"

"@reapit/[email protected]":
version "1.0.0-alpha.1"
resolved "https://registry.yarnpkg.com/@reapit/connect-session/-/connect-session-1.0.0-alpha.1.tgz#4c06af14318a8dd355d6a5a233f3f1db0bc26402"
integrity sha512-v07IY2skFIz/PZvNsd5ZucVyaEunWMigt/QIBELZdYC4zcphFCQJ4d1PuqYnTqkoc+dxWjXyLV4NVL2qzu/XtQ==
dependencies:
isomorphic-fetch "^2.2.1"
jsonwebtoken "^8.5.1"
snyk "^1.335.0"

"@reapit/[email protected]", "@reapit/connect-session@^1.0.0-alpha.1", "@reapit/connect-session@^1.0.0-alpha.2", "@reapit/connect-session@^1.0.0-alpha.3":
version "1.0.1"
resolved "https://registry.yarnpkg.com/@reapit/connect-session/-/connect-session-1.0.1.tgz#a8feaf97b10a8f53cf8b1c012353c77620823dd8"
Expand Down