Commit a7858ab6 authored by tom's avatar tom

redirect from account if there is no cookie

parent a88851a4
const { NextResponse } = require('next/server');
const NETWORKS = require('lib/networks/availableNetworks').default;
export function middleware(req) {
const [ , networkType, networkSubtype ] = req.nextUrl.pathname.split('/');
const selectedNetwork = NETWORKS.find(({ type, subType }) =>
type === networkType && (subType ? subType === networkSubtype : true));
if (selectedNetwork) {
const apiToken = req.cookies.get('_explorer_key');
if (!apiToken) {
const authPath = `/${ selectedNetwork.type }/${ selectedNetwork.subType }auth/auth0`;
return NextResponse.redirect(new URL(authPath, 'https://blockscout.com/'));
}
}
}
export const config = {
matcher: '/:network_type/:network_sub_type/account/:path*',
};
...@@ -23,7 +23,7 @@ const moduleExports = { ...@@ -23,7 +23,7 @@ const moduleExports = {
{ {
source: '/', source: '/',
destination: '/poa/core', destination: '/poa/core',
permanent: true, permanent: false,
}, },
]; ];
}, },
......
...@@ -1380,10 +1380,10 @@ ...@@ -1380,10 +1380,10 @@
resolved "https://registry.yarnpkg.com/@next/env/-/env-12.2.5.tgz#d908c57b35262b94db3e431e869b72ac3e1ad3e3" resolved "https://registry.yarnpkg.com/@next/env/-/env-12.2.5.tgz#d908c57b35262b94db3e431e869b72ac3e1ad3e3"
integrity sha512-vLPLV3cpPGjUPT3PjgRj7e3nio9t6USkuew3JE/jMeon/9Mvp1WyR18v3iwnCuX7eUAm1HmAbJHHLAbcu/EJcw== integrity sha512-vLPLV3cpPGjUPT3PjgRj7e3nio9t6USkuew3JE/jMeon/9Mvp1WyR18v3iwnCuX7eUAm1HmAbJHHLAbcu/EJcw==
"@next/eslint-plugin-next@12.1.6": "@next/eslint-plugin-next@12.3.0":
version "12.1.6" version "12.3.0"
resolved "https://registry.yarnpkg.com/@next/eslint-plugin-next/-/eslint-plugin-next-12.1.6.tgz#dde3f98831f15923b25244588d924c716956292e" resolved "https://registry.yarnpkg.com/@next/eslint-plugin-next/-/eslint-plugin-next-12.3.0.tgz#302c1f03618d5001ce92ea6826c329268759128e"
integrity sha512-yNUtJ90NEiYFT6TJnNyofKMPYqirKDwpahcbxBgSIuABwYOdkGwzos1ZkYD51Qf0diYwpQZBeVqElTk7Q2WNqw== integrity sha512-jVdq1qYTNDjUtulnE8/hkPv0pHILV4jMg5La99iaY/FFm20WxVnsAZtbNnMvlPbf8dc010oO304SX9yXbg5PAw==
dependencies: dependencies:
glob "7.1.7" glob "7.1.7"
...@@ -2709,12 +2709,12 @@ escape-string-regexp@^4.0.0: ...@@ -2709,12 +2709,12 @@ escape-string-regexp@^4.0.0:
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34" resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34"
integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA== integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==
eslint-config-next@12.1.6: eslint-config-next@^12.3.0:
version "12.1.6" version "12.3.0"
resolved "https://registry.yarnpkg.com/eslint-config-next/-/eslint-config-next-12.1.6.tgz#55097028982dce49159d8753000be3916ac55254" resolved "https://registry.yarnpkg.com/eslint-config-next/-/eslint-config-next-12.3.0.tgz#d887ab2d143fe1a2b308e9321e932a613e610800"
integrity sha512-qoiS3g/EPzfCTkGkaPBSX9W0NGE/B1wNO3oWrd76QszVGrdpLggNqcO8+LR6MB0CNqtp9Q8NoeVrxNVbzM9hqA== integrity sha512-guHSkNyKnTBB8HU35COgAMeMV0E026BiYRYvyEVVaTOeFcnU3i1EI8/Da0Rl7H3Sgua5FEvoA0vYd2s8kdIUXg==
dependencies: dependencies:
"@next/eslint-plugin-next" "12.1.6" "@next/eslint-plugin-next" "12.3.0"
"@rushstack/eslint-patch" "^1.1.3" "@rushstack/eslint-patch" "^1.1.3"
"@typescript-eslint/parser" "^5.21.0" "@typescript-eslint/parser" "^5.21.0"
eslint-import-resolver-node "^0.3.6" eslint-import-resolver-node "^0.3.6"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment