-
{t('Restore password')}
-
- {t(message()) || t('Everything is ok, please give us your email address')}
-
+
{t('Set the new password')}
+
{t(message()) || t('Please give us your email address')}
{
disabled={isSubmitting() || Boolean(message())}
type="submit"
>
- {isSubmitting() ? '...' : t('Restore password')}
+ {isSubmitting() ? '...' : t('Send')}
diff --git a/src/components/Nav/AuthModal/index.tsx b/src/components/Nav/AuthModal/index.tsx
index c6b03ee8..760e58a0 100644
--- a/src/components/Nav/AuthModal/index.tsx
+++ b/src/components/Nav/AuthModal/index.tsx
@@ -11,16 +11,16 @@ import { isMobile } from '../../../utils/media-query'
import { ChangePasswordForm } from './ChangePasswordForm'
import { EmailConfirm } from './EmailConfirm'
-import { ForgotPasswordForm } from './ForgotPasswordForm'
import { LoginForm } from './LoginForm'
import { RegisterForm } from './RegisterForm'
+import { SendResetLinkForm } from './SendResetLinkForm'
import styles from './AuthModal.module.scss'
const AUTH_MODAL_MODES: Record
= {
login: LoginForm,
register: RegisterForm,
- 'forgot-password': ForgotPasswordForm,
+ 'send-reset-link': SendResetLinkForm,
'confirm-email': EmailConfirm,
'change-password': ChangePasswordForm,
}
diff --git a/src/components/Nav/AuthModal/types.ts b/src/components/Nav/AuthModal/types.ts
index 92efe4ea..e2db3e78 100644
--- a/src/components/Nav/AuthModal/types.ts
+++ b/src/components/Nav/AuthModal/types.ts
@@ -1,4 +1,4 @@
-export type AuthModalMode = 'login' | 'register' | 'confirm-email' | 'forgot-password' | 'change-password'
+export type AuthModalMode = 'login' | 'register' | 'confirm-email' | 'send-reset-link' | 'change-password'
export type AuthModalSource =
| 'discussions'
| 'vote'
diff --git a/src/context/session.tsx b/src/context/session.tsx
index 944283e6..8da23006 100644
--- a/src/context/session.tsx
+++ b/src/context/session.tsx
@@ -11,6 +11,7 @@ import {
ForgotPasswordResponse,
GenericResponse,
LoginInput,
+ ResendVerifyEmailInput,
SignupInput,
VerifyEmailInput,
} from '@authorizerdev/authorizer-js'
@@ -68,6 +69,8 @@ export type SessionContextType = {
confirmEmail: (input: VerifyEmailInput) => Promise // email confirm callback is in auth.discours.io
setIsSessionLoaded: (loaded: boolean) => void
authorizer: () => Authorizer
+ isRegistered: (email: string) => Promise
+ resendVerifyEmail: (params: ResendVerifyEmailInput) => Promise
}
const noop = () => {}
@@ -309,6 +312,31 @@ export const SessionProvider = (props: {
return { data: resp?.data, errors: resp.errors }
}
+ const resendVerifyEmail = async (params: ResendVerifyEmailInput) => {
+ const resp = await authorizer().resendVerifyEmail(params)
+ console.debug('[context.session] resend verify email response:', resp)
+ if (resp.errors) {
+ resp.errors.forEach((error) => {
+ showSnackbar({ type: 'error', body: error.message })
+ })
+ }
+ return resp?.data
+ }
+
+ const isRegistered = async (email: string): Promise => {
+ console.debug('[context.session] calling is_registered for ', email)
+ try {
+ const response = await authorizer().graphqlQuery({
+ query: `query { is_registered(email: "${email}") { message }}`,
+ })
+ // console.log(response)
+ return response?.data?.is_registered?.message
+ } catch (error) {
+ console.warn(error)
+ }
+ return ''
+ }
+
const confirmEmail = async (input: VerifyEmailInput) => {
console.debug(`[context.session] calling authorizer's verify email with`, input)
try {
@@ -348,6 +376,7 @@ export const SessionProvider = (props: {
forgotPassword,
changePassword,
oauth,
+ isRegistered,
}
const value: SessionContextType = {
authError,
@@ -357,6 +386,7 @@ export const SessionProvider = (props: {
author,
...actions,
isAuthenticated,
+ resendVerifyEmail,
}
return {props.children}
diff --git a/src/stores/emailChecks.ts b/src/stores/emailChecks.ts
deleted file mode 100644
index b8e4875c..00000000
--- a/src/stores/emailChecks.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-import { createSignal } from 'solid-js'
-
-const [emailChecks, setEmailChecks] = createSignal<{ [email: string]: boolean }>({})
-
-export const checkEmail = async (email: string): Promise => {
- if (emailChecks()[email]) {
- return true
- }
- const checkResult = false // FIXME: secure endpoint for check email
-
- if (checkResult) {
- setEmailChecks((oldEmailChecks) => ({ ...oldEmailChecks, [email]: true }))
- return true
- }
-
- return false
-}
-
-export const useEmailChecks = () => {
- return { emailChecks }
-}
diff --git a/vite.config.ts b/vite.config.ts
index 3c33b875..f5146681 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -51,7 +51,8 @@ export default defineConfig(({ mode, command }) => {
envPrefix: 'PUBLIC_',
plugins,
server: {
- https: true,
+ cors: isDev,
+ https: {},
port: 3000,
},
css: {
@@ -78,6 +79,8 @@ export default defineConfig(({ mode, command }) => {
'wonka',
'solid-popper',
'seroval',
+ 'seroval-plugins',
+ 'seroval-plugins/web',
'@solid-primitives/share',
'i18next',
'js-cookie',