chore: carify Pomade login errors with actionable invalid vs network messaging #233
@@ -19,6 +19,7 @@
|
||||
import LogInOTP from "@app/components/LogInOTP.svelte"
|
||||
import LogInSelect from "@app/components/LogInSelect.svelte"
|
||||
import {deleteDeactivatedPomadeSessions, loginWithPomade} from "@app/util/pomade"
|
||||
import {getPomadeLoginFailureMessage, POMADE_NETWORK_ERROR_MESSAGE} from "@app/util/pomadeErrors"
|
||||
import {pushModal, clearModals} from "@app/util/modal"
|
||||
import {setChecked} from "@app/util/notifications"
|
||||
import {pushToast} from "@app/util/toast"
|
||||
@@ -44,7 +45,7 @@
|
||||
|
||||
return pushToast({
|
||||
theme: "error",
|
||||
message: "Sorry, we were unable to log you in.",
|
||||
message: getPomadeLoginFailureMessage(messages),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -64,10 +65,17 @@
|
||||
|
||||
pushToast({
|
||||
theme: "error",
|
||||
message: "Sorry, we were unable to log you in.",
|
||||
message: getPomadeLoginFailureMessage(res.messages),
|
||||
})
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Login error:", error)
|
||||
|
||||
pushToast({
|
||||
theme: "error",
|
||||
message: POMADE_NETWORK_ERROR_MESSAGE,
|
||||
})
|
||||
} finally {
|
||||
loading = false
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
import ModalSubtitle from "@lib/components/ModalSubtitle.svelte"
|
||||
import ModalFooter from "@lib/components/ModalFooter.svelte"
|
||||
import LogInOTPConfirm from "@app/components/LogInOTPConfirm.svelte"
|
||||
import {POMADE_NETWORK_ERROR_MESSAGE} from "@app/util/pomadeErrors"
|
||||
import {pushModal} from "@app/util/modal"
|
||||
import {pushToast} from "@app/util/toast"
|
||||
|
||||
@@ -35,11 +36,20 @@
|
||||
if (ok) {
|
||||
pushModal(LogInOTPConfirm, {email, peersByPrefix})
|
||||
} else {
|
||||
console.error("Pomade challenge request failed during OTP login")
|
||||
|
||||
pushToast({
|
||||
theme: "error",
|
||||
message: "Sorry, we were unable to request a login code.",
|
||||
message: POMADE_NETWORK_ERROR_MESSAGE,
|
||||
})
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
|
||||
pushToast({
|
||||
theme: "error",
|
||||
message: POMADE_NETWORK_ERROR_MESSAGE,
|
||||
})
|
||||
} finally {
|
||||
loading = false
|
||||
}
|
||||
|
||||
@@ -15,10 +15,11 @@
|
||||
import ModalFooter from "@lib/components/ModalFooter.svelte"
|
||||
import StringMultiInput from "@lib/components/StringMultiInput.svelte"
|
||||
import LogInSelect from "@app/components/LogInSelect.svelte"
|
||||
import {pushToast} from "@app/util/toast"
|
||||
import {setChecked} from "@app/util/notifications"
|
||||
import {pushModal, clearModals} from "@app/util/modal"
|
||||
import {setChecked} from "@app/util/notifications"
|
||||
import {deleteDeactivatedPomadeSessions, loginWithPomade} from "@app/util/pomade"
|
||||
import {getPomadeLoginFailureMessage, POMADE_NETWORK_ERROR_MESSAGE} from "@app/util/pomadeErrors"
|
||||
import {pushToast} from "@app/util/toast"
|
||||
|
||||
type Props = {
|
||||
email: string
|
||||
@@ -44,7 +45,7 @@
|
||||
|
||||
return pushToast({
|
||||
theme: "error",
|
||||
message: "Sorry, we were unable to log you in.",
|
||||
message: getPomadeLoginFailureMessage(messages),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -64,10 +65,17 @@
|
||||
|
||||
pushToast({
|
||||
theme: "error",
|
||||
message: "Sorry, we were unable to log you in.",
|
||||
message: getPomadeLoginFailureMessage(res.messages),
|
||||
})
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Login error:", error)
|
||||
|
||||
pushToast({
|
||||
theme: "error",
|
||||
message: POMADE_NETWORK_ERROR_MESSAGE,
|
||||
})
|
||||
} finally {
|
||||
loading = false
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
import ModalFooter from "@lib/components/ModalFooter.svelte"
|
||||
import Profile from "@app/components/Profile.svelte"
|
||||
import {deleteDeactivatedPomadeSessions, loginWithPomade} from "@app/util/pomade"
|
||||
import {getPomadeLoginFailureMessage, POMADE_NETWORK_ERROR_MESSAGE} from "@app/util/pomadeErrors"
|
||||
import {setChecked} from "@app/util/notifications"
|
||||
import {clearModals} from "@app/util/modal"
|
||||
import {pushToast} from "@app/util/toast"
|
||||
@@ -46,9 +47,16 @@
|
||||
|
||||
pushToast({
|
||||
theme: "error",
|
||||
message: "Sorry, we were unable to log you in.",
|
||||
message: getPomadeLoginFailureMessage(res.messages),
|
||||
})
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Login error:", error)
|
||||
|
||||
pushToast({
|
||||
theme: "error",
|
||||
message: POMADE_NETWORK_ERROR_MESSAGE,
|
||||
})
|
||||
} finally {
|
||||
loading = false
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
export const POMADE_INVALID_LOGIN_MESSAGE = "Invalid login information"
|
||||
export const POMADE_NETWORK_ERROR_MESSAGE = "Network error, please try again"
|
||||
|
||||
type PomadeMessage = {
|
||||
res?: unknown
|
||||
}
|
||||
|
||||
export const getPomadeLoginFailureMessage = (messages: PomadeMessage[]) =>
|
||||
messages.some(message => message.res !== undefined)
|
||||
? POMADE_INVALID_LOGIN_MESSAGE
|
||||
: POMADE_NETWORK_ERROR_MESSAGE
|
||||
@@ -27,6 +27,7 @@
|
||||
import PasswordReset from "@app/components/PasswordReset.svelte"
|
||||
import InfoKeys from "@app/components/InfoKeys.svelte"
|
||||
import {pushModal} from "@app/util/modal"
|
||||
import {POMADE_NETWORK_ERROR_MESSAGE} from "@app/util/pomadeErrors"
|
||||
import {clip, pushToast} from "@app/util/toast"
|
||||
|
||||
const npub = nip19.npubEncode($pubkey!)
|
||||
@@ -48,13 +49,24 @@
|
||||
const {ok, peersByPrefix} = await Client.requestChallenge($session!.email)
|
||||
|
||||
if (!ok) {
|
||||
console.error("Pomade challenge request failed during password reset initiation")
|
||||
|
||||
pushToast({
|
||||
theme: "error",
|
||||
message: "Failed to initiate password reset!",
|
||||
message: POMADE_NETWORK_ERROR_MESSAGE,
|
||||
})
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
pushModal(PasswordReset, {peersByPrefix})
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
|
||||
pushToast({
|
||||
theme: "error",
|
||||
message: POMADE_NETWORK_ERROR_MESSAGE,
|
||||
})
|
||||
} finally {
|
||||
loading = false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user