chore: fix error handling in login page
All checks were successful
Release / build_and_release (push) Successful in 42s
All checks were successful
Release / build_and_release (push) Successful in 42s
This commit is contained in:
parent
560cf84799
commit
34e7a34bd7
@ -109,6 +109,12 @@ export const Login = () => {
|
||||
|
||||
setIsLoading(true)
|
||||
|
||||
const displayError = (message: string) => {
|
||||
toast.error(message)
|
||||
setIsLoading(false)
|
||||
setLoadingSpinnerDesc('')
|
||||
}
|
||||
|
||||
if (inputValue.includes('@')) {
|
||||
const nip05Profile = await nip05.queryProfile(inputValue).catch((err) => {
|
||||
toast.error('An error occurred while querying nip05 profile: ' + err)
|
||||
@ -128,16 +134,14 @@ export const Login = () => {
|
||||
})
|
||||
|
||||
if (!metadataEvent) {
|
||||
toast.error('metadata not found!')
|
||||
return
|
||||
return displayError('metadata not found!')
|
||||
}
|
||||
|
||||
const metadataContent =
|
||||
metadataController.extractProfileMetadataContent(metadataEvent)
|
||||
|
||||
if (!metadataContent?.nip05) {
|
||||
toast.error('nip05 not present in metadata')
|
||||
return
|
||||
return displayError('nip05 not present in metadata')
|
||||
}
|
||||
|
||||
const nip05Profile = await nip05.queryProfile(inputValue).catch((err) => {
|
||||
@ -147,8 +151,9 @@ export const Login = () => {
|
||||
|
||||
if (nip05Profile) {
|
||||
if (nip05Profile.pubkey !== pubkey) {
|
||||
toast.error('pubkey in nip05 does not match with provided npub')
|
||||
return
|
||||
return displayError(
|
||||
'pubkey in nip05 does not match with provided npub'
|
||||
)
|
||||
}
|
||||
|
||||
relays = nip05Profile.relays
|
||||
@ -156,13 +161,11 @@ export const Login = () => {
|
||||
}
|
||||
|
||||
if (!relays || relays.length === 0) {
|
||||
toast.error('No relay found for nsecbunker')
|
||||
return
|
||||
return displayError('No relay found for nsecbunker')
|
||||
}
|
||||
|
||||
if (!pubkey) {
|
||||
toast.error('pubkey not found')
|
||||
return
|
||||
return displayError('pubkey not found')
|
||||
}
|
||||
|
||||
setLoadingSpinnerDesc('Initializing nsecBunker')
|
||||
|
Loading…
Reference in New Issue
Block a user