sended link status, sign out revoke token
This commit is contained in:
parent
1574fc083b
commit
e609eb09fa
|
@ -22,7 +22,7 @@ export const ForgotPasswordForm = () => {
|
|||
setValidationErrors(({ email: _notNeeded, ...rest }) => rest)
|
||||
setEmail(newEmail)
|
||||
}
|
||||
|
||||
const [sended, setSended] = createSignal(false)
|
||||
const [submitError, setSubmitError] = createSignal('')
|
||||
const [isSubmitting, setIsSubmitting] = createSignal(false)
|
||||
const [validationErrors, setValidationErrors] = createSignal<ValidationErrors>({})
|
||||
|
@ -53,6 +53,7 @@ export const ForgotPasswordForm = () => {
|
|||
try {
|
||||
const result = await signSendLink({ email: email(), lang: locale() })
|
||||
if (result.error) setSubmitError(result.error)
|
||||
else setSended(true)
|
||||
} catch (error) {
|
||||
setSubmitError(error.message)
|
||||
} finally {
|
||||
|
@ -63,7 +64,12 @@ export const ForgotPasswordForm = () => {
|
|||
return (
|
||||
<form onSubmit={handleSubmit}>
|
||||
<h4>{t('Forgot password?')}</h4>
|
||||
<div class={styles.authSubtitle}>{t('Everything is ok, please give us your email address')}</div>
|
||||
<Show
|
||||
when={!sended()}
|
||||
fallback={<div class={styles.authInfo}>{t('Link sent, check your email')}</div>}
|
||||
>
|
||||
<div class={styles.authSubtitle}>{t('Everything is ok, please give us your email address')}</div>
|
||||
</Show>
|
||||
<Show when={submitError()}>
|
||||
<div class={styles.authInfo}>
|
||||
<ul>
|
||||
|
|
|
@ -11,11 +11,15 @@ export const signIn = async (params) => {
|
|||
setToken(authResult.token)
|
||||
console.debug('signed in')
|
||||
}
|
||||
export const signOut = () => {
|
||||
// TODO: call backend to revoke token
|
||||
setSession(null)
|
||||
resetToken()
|
||||
console.debug('signed out')
|
||||
export const signOut = async () => {
|
||||
const result = await apiClient.authSignOut()
|
||||
if (result.error) {
|
||||
console.error('[auth] sign out error', result.error)
|
||||
} else {
|
||||
setSession(null)
|
||||
resetToken()
|
||||
console.debug('signed out')
|
||||
}
|
||||
}
|
||||
|
||||
export const [emailChecks, setEmailChecks] = createSignal<{ [email: string]: boolean }>({})
|
||||
|
|
Loading…
Reference in New Issue
Block a user