Compare commits

..

No commits in common. "f76408ba511de1eb2af332839dea9f2730a94521" and "f7723a3ee9d37f3046e327525254fb3947d394b1" have entirely different histories.

2 changed files with 17 additions and 29 deletions

View File

@ -33,14 +33,6 @@ const App = () => {
}
}
const handleRootRedirect = () => {
if (authState.loggedIn) return appPrivateRoutes.homePage
const callbackPathEncoded = btoa(
window.location.href.split(`${window.location.origin}/#`)[1]
)
return `${appPublicRoutes.login}?callbackPath=${callbackPathEncoded}`
}
return (
<Routes>
<Route element={<MainLayout />}>
@ -74,7 +66,18 @@ const App = () => {
}
})}
<Route path="*" element={<Navigate to={handleRootRedirect()} />} />
<Route
path="*"
element={
<Navigate
to={
authState.loggedIn
? appPrivateRoutes.homePage
: appPublicRoutes.login
}
/>
}
/>
</Route>
</Routes>
)

View File

@ -2,7 +2,7 @@ import { Box, Button, TextField, Typography } from '@mui/material'
import { getPublicKey, nip19 } from 'nostr-tools'
import { useEffect, useState } from 'react'
import { useDispatch } from 'react-redux'
import { useNavigate, useSearchParams } from 'react-router-dom'
import { useNavigate } from 'react-router-dom'
import { toast } from 'react-toastify'
import { LoadingSpinner } from '../../components/LoadingSpinner'
import {
@ -22,8 +22,6 @@ import { npubToHex, queryNip05 } from '../../utils'
import styles from './style.module.scss'
export const Login = () => {
const [searchParams] = useSearchParams()
const dispatch: Dispatch = useDispatch()
const navigate = useNavigate()
@ -55,19 +53,6 @@ export const Login = () => {
}
}
const navigateAfterLogin = (path: string) => {
const callbackPath = searchParams.get('callbackPath')
if (callbackPath) {
// base64 decoded path
const path = atob(callbackPath)
navigate(path)
return
}
navigate(path)
}
const loginWithExtension = async () => {
setIsLoading(true)
setLoadingSpinnerDesc('Capturing pubkey from nostr extension')
@ -81,7 +66,7 @@ export const Login = () => {
const redirectPath =
await authController.authenticateAndFindMetadata(pubkey)
navigateAfterLogin(redirectPath)
navigate(redirectPath)
})
.catch((err) => {
toast.error('Error capturing public key from nostr extension: ' + err)
@ -124,7 +109,7 @@ export const Login = () => {
return null
})
if (redirectPath) navigateAfterLogin(redirectPath)
if (redirectPath) navigate(redirectPath)
setIsLoading(false)
setLoadingSpinnerDesc('')
@ -219,7 +204,7 @@ export const Login = () => {
return null
})
if (redirectPath) navigateAfterLogin(redirectPath)
if (redirectPath) navigate(redirectPath)
})
.catch((err) => {
toast.error(
@ -279,7 +264,7 @@ export const Login = () => {
return null
})
if (redirectPath) navigateAfterLogin(redirectPath)
if (redirectPath) navigate(redirectPath)
})
.catch((err) => {
toast.error(