Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
frontend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
frontend
Commits
f3ecc07e
Commit
f3ecc07e
authored
Feb 15, 2023
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auth route
parent
caa24a4f
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
36 additions
and
21 deletions
+36
-21
useLoginUrl.tsx
lib/hooks/useLoginUrl.tsx
+3
-2
link.ts
lib/link/link.ts
+2
-1
routes.ts
lib/link/routes.ts
+11
-12
middleware.ts
middleware.ts
+2
-2
index.tsx
pages/auth/index.tsx
+13
-0
nextjs-routes.d.ts
types/nextjs-routes.d.ts
+1
-0
MarketplaceApp.tsx
ui/pages/MarketplaceApp.tsx
+4
-4
No files found.
lib/hooks/useLoginUrl.tsx
View file @
f3ecc07e
import
{
useRouter
}
from
'
next/router
'
;
import
{
useRouter
}
from
'
next/router
'
;
import
{
route
}
from
'
nextjs-routes
'
;
import
link
from
'
lib/link/link
'
;
import
appConfig
from
'
configs/app/config
'
;
export
default
function
useLoginUrl
()
{
export
default
function
useLoginUrl
()
{
const
router
=
useRouter
();
const
router
=
useRouter
();
return
link
(
'
auth
'
,
{},
{
path
:
router
.
asPath
});
return
appConfig
.
authUrl
+
route
({
pathname
:
'
/auth
'
,
query
:
{
path
:
router
.
asPath
}
});
}
}
lib/link/link.ts
View file @
f3ecc07e
...
@@ -28,7 +28,8 @@ export default function link(
...
@@ -28,7 +28,8 @@ export default function link(
return
paramValue
?
`/
${
paramValue
}
`
:
''
;
return
paramValue
?
`/
${
paramValue
}
`
:
''
;
});
});
const
baseUrl
=
routeName
===
'
auth
'
?
appConfig
.
authUrl
:
appConfig
.
baseUrl
;
// const baseUrl = routeName === 'auth' ? appConfig.authUrl : appConfig.baseUrl;
const
baseUrl
=
appConfig
.
baseUrl
;
const
url
=
new
URL
(
path
,
baseUrl
);
const
url
=
new
URL
(
path
,
baseUrl
);
...
...
lib/link/routes.ts
View file @
f3ecc07e
...
@@ -11,11 +11,10 @@ export type RouteName = keyof typeof ROUTES;
...
@@ -11,11 +11,10 @@ export type RouteName = keyof typeof ROUTES;
export
const
ROUTES
=
{
export
const
ROUTES
=
{
// NETWORK MAIN PAGE
// NETWORK MAIN PAGE
// todo_tom need full url builder
// network_index: {
network_index
:
{
// pattern: PATHS.network_index,
pattern
:
PATHS
.
network_index
,
// crossNetworkNavigation: true,
crossNetworkNavigation
:
true
,
// },
},
// ACCOUNT
// ACCOUNT
// watchlist: {
// watchlist: {
...
@@ -43,10 +42,9 @@ export const ROUTES = {
...
@@ -43,10 +42,9 @@ export const ROUTES = {
// crossNetworkNavigation: true,
// crossNetworkNavigation: true,
// },
// },
// todo_tom need full url builder
// tx: {
tx
:
{
// pattern: PATHS.tx,
pattern
:
PATHS
.
tx
,
// },
},
// BLOCKS
// BLOCKS
// blocks: {
// blocks: {
...
@@ -113,9 +111,10 @@ export const ROUTES = {
...
@@ -113,9 +111,10 @@ export const ROUTES = {
},
},
// AUTH
// AUTH
auth
:
{
// todo_tom need add page to the app
pattern
:
PATHS
.
auth
,
// auth: {
},
// pattern: PATHS.auth,
// },
};
};
// !!! for development purpose only !!!
// !!! for development purpose only !!!
...
...
middleware.ts
View file @
f3ecc07e
import
type
{
NextRequest
}
from
'
next/server
'
;
import
type
{
NextRequest
}
from
'
next/server
'
;
import
{
NextResponse
}
from
'
next/server
'
;
import
{
NextResponse
}
from
'
next/server
'
;
import
{
route
}
from
'
nextjs-routes
'
;
import
appConfig
from
'
configs/app/config
'
;
import
appConfig
from
'
configs/app/config
'
;
import
{
NAMES
}
from
'
lib/cookies
'
;
import
{
NAMES
}
from
'
lib/cookies
'
;
import
getCspPolicy
from
'
lib/csp/getCspPolicy
'
;
import
getCspPolicy
from
'
lib/csp/getCspPolicy
'
;
import
link
from
'
lib/link/link
'
;
const
cspPolicy
=
getCspPolicy
();
const
cspPolicy
=
getCspPolicy
();
...
@@ -22,7 +22,7 @@ export function middleware(req: NextRequest) {
...
@@ -22,7 +22,7 @@ export function middleware(req: NextRequest) {
const
apiToken
=
req
.
cookies
.
get
(
NAMES
.
API_TOKEN
);
const
apiToken
=
req
.
cookies
.
get
(
NAMES
.
API_TOKEN
);
if
((
isAccountRoute
||
isProfileRoute
)
&&
!
apiToken
&&
appConfig
.
isAccountSupported
)
{
if
((
isAccountRoute
||
isProfileRoute
)
&&
!
apiToken
&&
appConfig
.
isAccountSupported
)
{
const
authUrl
=
link
(
'
auth
'
,
undefined
,
{
path
:
req
.
nextUrl
.
pathname
});
const
authUrl
=
appConfig
.
authUrl
+
route
({
pathname
:
'
/auth
'
,
query
:
{
path
:
req
.
nextUrl
.
pathname
}
});
return
NextResponse
.
redirect
(
authUrl
);
return
NextResponse
.
redirect
(
authUrl
);
}
}
...
...
pages/auth/index.tsx
0 → 100644
View file @
f3ecc07e
import
type
{
NextPage
}
from
'
next
'
;
const
AuthPage
:
NextPage
=
()
=>
{
return
null
;
};
export
default
AuthPage
;
export
async
function
getServerSideProps
()
{
return
{
notFound
:
true
,
};
}
types/nextjs-routes.d.ts
View file @
f3ecc07e
...
@@ -18,6 +18,7 @@ declare module "nextjs-routes" {
...
@@ -18,6 +18,7 @@ declare module "nextjs-routes" {
|
StaticRoute
<
"
/api/proxy
"
>
|
StaticRoute
<
"
/api/proxy
"
>
|
DynamicRoute
<
"
/apps/[id]
"
,
{
"
id
"
:
string
}
>
|
DynamicRoute
<
"
/apps/[id]
"
,
{
"
id
"
:
string
}
>
|
StaticRoute
<
"
/apps
"
>
|
StaticRoute
<
"
/apps
"
>
|
StaticRoute
<
"
/auth
"
>
|
StaticRoute
<
"
/auth/profile
"
>
|
StaticRoute
<
"
/auth/profile
"
>
|
DynamicRoute
<
"
/block/[height]
"
,
{
"
height
"
:
string
}
>
|
DynamicRoute
<
"
/block/[height]
"
,
{
"
height
"
:
string
}
>
|
StaticRoute
<
"
/blocks
"
>
|
StaticRoute
<
"
/blocks
"
>
...
...
ui/pages/MarketplaceApp.tsx
View file @
f3ecc07e
import
{
Box
,
Center
,
useColorMode
}
from
'
@chakra-ui/react
'
;
import
{
Box
,
Center
,
useColorMode
}
from
'
@chakra-ui/react
'
;
import
{
route
}
from
'
nextjs-routes
'
;
import
React
,
{
useCallback
,
useEffect
,
useRef
,
useState
}
from
'
react
'
;
import
React
,
{
useCallback
,
useEffect
,
useRef
,
useState
}
from
'
react
'
;
import
type
{
AppItemOverview
}
from
'
types/client/apps
'
;
import
type
{
AppItemOverview
}
from
'
types/client/apps
'
;
import
appConfig
from
'
configs/app/config
'
;
import
appConfig
from
'
configs/app/config
'
;
import
link
from
'
lib/link/link
'
;
import
ContentLoader
from
'
ui/shared/ContentLoader
'
;
import
ContentLoader
from
'
ui/shared/ContentLoader
'
;
import
Page
from
'
ui/shared/Page/Page
'
;
import
Page
from
'
ui/shared/Page/Page
'
;
...
@@ -26,9 +26,9 @@ const MarketplaceApp = ({ app, isLoading }: Props) => {
...
@@ -26,9 +26,9 @@ const MarketplaceApp = ({ app, isLoading }: Props) => {
if
(
app
&&
!
isFrameLoading
)
{
if
(
app
&&
!
isFrameLoading
)
{
const
message
=
{
const
message
=
{
blockscoutColorMode
:
colorMode
,
blockscoutColorMode
:
colorMode
,
blockscoutRootUrl
:
link
(
'
network_index
'
),
blockscoutRootUrl
:
appConfig
.
baseUrl
+
route
({
pathname
:
'
/
'
}
),
blockscoutAddressExplorerUrl
:
link
(
'
address_index
'
),
blockscoutAddressExplorerUrl
:
appConfig
.
baseUrl
+
route
({
pathname
:
'
/address/[id]
'
,
query
:
{
id
:
''
}
}
),
blockscoutTransactionExplorerUrl
:
link
(
'
tx
'
),
blockscoutTransactionExplorerUrl
:
appConfig
.
baseUrl
+
route
({
pathname
:
'
/tx/[hash]
'
,
query
:
{
hash
:
''
}
}
),
blockscoutNetworkName
:
appConfig
.
network
.
name
,
blockscoutNetworkName
:
appConfig
.
network
.
name
,
blockscoutNetworkId
:
Number
(
appConfig
.
network
.
id
),
blockscoutNetworkId
:
Number
(
appConfig
.
network
.
id
),
blockscoutNetworkCurrency
:
appConfig
.
network
.
currency
,
blockscoutNetworkCurrency
:
appConfig
.
network
.
currency
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment