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)
|
setIsLoading(true)
|
||||||
|
|
||||||
|
const displayError = (message: string) => {
|
||||||
|
toast.error(message)
|
||||||
|
setIsLoading(false)
|
||||||
|
setLoadingSpinnerDesc('')
|
||||||
|
}
|
||||||
|
|
||||||
if (inputValue.includes('@')) {
|
if (inputValue.includes('@')) {
|
||||||
const nip05Profile = await nip05.queryProfile(inputValue).catch((err) => {
|
const nip05Profile = await nip05.queryProfile(inputValue).catch((err) => {
|
||||||
toast.error('An error occurred while querying nip05 profile: ' + err)
|
toast.error('An error occurred while querying nip05 profile: ' + err)
|
||||||
@ -128,16 +134,14 @@ export const Login = () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
if (!metadataEvent) {
|
if (!metadataEvent) {
|
||||||
toast.error('metadata not found!')
|
return displayError('metadata not found!')
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const metadataContent =
|
const metadataContent =
|
||||||
metadataController.extractProfileMetadataContent(metadataEvent)
|
metadataController.extractProfileMetadataContent(metadataEvent)
|
||||||
|
|
||||||
if (!metadataContent?.nip05) {
|
if (!metadataContent?.nip05) {
|
||||||
toast.error('nip05 not present in metadata')
|
return displayError('nip05 not present in metadata')
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const nip05Profile = await nip05.queryProfile(inputValue).catch((err) => {
|
const nip05Profile = await nip05.queryProfile(inputValue).catch((err) => {
|
||||||
@ -147,8 +151,9 @@ export const Login = () => {
|
|||||||
|
|
||||||
if (nip05Profile) {
|
if (nip05Profile) {
|
||||||
if (nip05Profile.pubkey !== pubkey) {
|
if (nip05Profile.pubkey !== pubkey) {
|
||||||
toast.error('pubkey in nip05 does not match with provided npub')
|
return displayError(
|
||||||
return
|
'pubkey in nip05 does not match with provided npub'
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
relays = nip05Profile.relays
|
relays = nip05Profile.relays
|
||||||
@ -156,13 +161,11 @@ export const Login = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!relays || relays.length === 0) {
|
if (!relays || relays.length === 0) {
|
||||||
toast.error('No relay found for nsecbunker')
|
return displayError('No relay found for nsecbunker')
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!pubkey) {
|
if (!pubkey) {
|
||||||
toast.error('pubkey not found')
|
return displayError('pubkey not found')
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setLoadingSpinnerDesc('Initializing nsecBunker')
|
setLoadingSpinnerDesc('Initializing nsecBunker')
|
||||||
|
Loading…
Reference in New Issue
Block a user