Skip to content

Commit 59cbe90

Browse files
christian-byrnegithub-actions
andauthored
[API Node] Reset password (#3578)
Co-authored-by: github-actions <[email protected]>
1 parent 16bd9ab commit 59cbe90

File tree

9 files changed

+53
-2
lines changed

9 files changed

+53
-2
lines changed

src/components/dialog/content/signin/SignInForm.vue

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@
3636
>
3737
{{ t('auth.login.passwordLabel') }}
3838
</label>
39-
<span class="text-muted text-base font-medium cursor-pointer">
39+
<span
40+
class="text-muted text-base font-medium cursor-pointer"
41+
@click="handleForgotPassword($form.email?.value)"
42+
>
4043
{{ t('auth.login.forgotPassword') }}
4144
</span>
4245
</div>
@@ -79,11 +82,13 @@ import { useI18n } from 'vue-i18n'
7982
8083
import { type SignInData, signInSchema } from '@/schemas/signInSchema'
8184
import { useFirebaseAuthStore } from '@/stores/firebaseAuthStore'
85+
import { useToastStore } from '@/stores/toastStore'
8286
8387
const authStore = useFirebaseAuthStore()
8488
const loading = computed(() => authStore.loading)
8589
8690
const { t } = useI18n()
91+
const toast = useToastStore()
8792
8893
const emit = defineEmits<{
8994
submit: [values: SignInData]
@@ -94,4 +99,22 @@ const onSubmit = (event: FormSubmitEvent) => {
9499
emit('submit', event.values as SignInData)
95100
}
96101
}
102+
103+
const handleForgotPassword = async (email: string) => {
104+
if (!email) return
105+
await authStore.sendPasswordReset(email)
106+
if (authStore.error) {
107+
toast.add({
108+
severity: 'error',
109+
summary: t('auth.login.forgotPasswordError'),
110+
detail: authStore.error
111+
})
112+
} else {
113+
toast.add({
114+
severity: 'success',
115+
summary: t('auth.login.passwordResetSent'),
116+
detail: t('auth.login.passwordResetSentDetail')
117+
})
118+
}
119+
}
97120
</script>

src/locales/en/main.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,6 +1082,9 @@
10821082
"login": {
10831083
"title": "Log in to your account",
10841084
"signInOrSignUp": "Sign In / Sign Up",
1085+
"forgotPasswordError": "Failed to send password reset email",
1086+
"passwordResetSent": "Password reset email sent",
1087+
"passwordResetSentDetail": "Please check your email for a link to reset your password.",
10851088
"newUser": "New here?",
10861089
"signUp": "Sign up",
10871090
"emailLabel": "Email",

src/locales/es/main.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"emailPlaceholder": "Ingresa tu correo electrónico",
1818
"failed": "Inicio de sesión fallido",
1919
"forgotPassword": "¿Olvidaste tu contraseña?",
20+
"forgotPasswordError": "No se pudo enviar el correo electrónico para restablecer la contraseña",
2021
"genericErrorMessage": "Lo sentimos, hemos encontrado un error. Por favor, contacta con {supportEmail}.",
2122
"loginButton": "Iniciar sesión",
2223
"loginWithGithub": "Iniciar sesión con Github",
@@ -25,6 +26,8 @@
2526
"orContinueWith": "O continuar con",
2627
"passwordLabel": "Contraseña",
2728
"passwordPlaceholder": "Ingresa tu contraseña",
29+
"passwordResetSent": "Correo electrónico de restablecimiento de contraseña enviado",
30+
"passwordResetSentDetail": "Por favor, revisa tu correo electrónico para encontrar un enlace para restablecer tu contraseña.",
2831
"privacyLink": "Política de privacidad",
2932
"signInOrSignUp": "Iniciar sesión / Registrarse",
3033
"signUp": "Regístrate",

src/locales/fr/main.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"emailPlaceholder": "Entrez votre email",
1818
"failed": "Échec de la connexion",
1919
"forgotPassword": "Mot de passe oublié?",
20+
"forgotPasswordError": "Échec de l'envoi de l'e-mail de réinitialisation du mot de passe",
2021
"genericErrorMessage": "Désolé, une erreur s'est produite. Veuillez contacter {supportEmail}.",
2122
"loginButton": "Se connecter",
2223
"loginWithGithub": "Se connecter avec Github",
@@ -25,6 +26,8 @@
2526
"orContinueWith": "Ou continuer avec",
2627
"passwordLabel": "Mot de passe",
2728
"passwordPlaceholder": "Entrez votre mot de passe",
29+
"passwordResetSent": "E-mail de réinitialisation du mot de passe envoyé",
30+
"passwordResetSentDetail": "Veuillez vérifier votre e-mail pour un lien de réinitialisation de votre mot de passe.",
2831
"privacyLink": "Politique de confidentialité",
2932
"signInOrSignUp": "Se connecter / S’inscrire",
3033
"signUp": "S'inscrire",

src/locales/ja/main.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"emailPlaceholder": "メールアドレスを入力してください",
1818
"failed": "ログイン失敗",
1919
"forgotPassword": "パスワードを忘れましたか?",
20+
"forgotPasswordError": "パスワードリセット用メールの送信に失敗しました",
2021
"genericErrorMessage": "申し訳ありませんが、エラーが発生しました。{supportEmail} までご連絡ください。",
2122
"loginButton": "ログイン",
2223
"loginWithGithub": "Githubでログイン",
@@ -25,6 +26,8 @@
2526
"orContinueWith": "または以下で続ける",
2627
"passwordLabel": "パスワード",
2728
"passwordPlaceholder": "パスワードを入力してください",
29+
"passwordResetSent": "パスワードリセット用メールを送信しました",
30+
"passwordResetSentDetail": "パスワードをリセットするためのリンクが記載されたメールをご確認ください。",
2831
"privacyLink": "プライバシーポリシー",
2932
"signInOrSignUp": "サインイン / サインアップ",
3033
"signUp": "サインアップ",

src/locales/ko/main.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"emailPlaceholder": "이메일을 입력하세요",
1818
"failed": "로그인 실패",
1919
"forgotPassword": "비밀번호를 잊으셨나요?",
20+
"forgotPasswordError": "비밀번호 재설정 이메일 전송에 실패했습니다",
2021
"genericErrorMessage": "죄송합니다. 오류가 발생했습니다. {supportEmail}로 문의해 주세요.",
2122
"loginButton": "로그인",
2223
"loginWithGithub": "Github로 로그인",
@@ -25,6 +26,8 @@
2526
"orContinueWith": "또는 다음으로 계속",
2627
"passwordLabel": "비밀번호",
2728
"passwordPlaceholder": "비밀번호를 입력하세요",
29+
"passwordResetSent": "비밀번호 재설정 이메일이 전송되었습니다",
30+
"passwordResetSentDetail": "비밀번호를 재설정할 수 있는 링크가 포함된 이메일을 확인해 주세요.",
2831
"privacyLink": "개인정보 보호정책",
2932
"signInOrSignUp": "로그인 / 회원가입",
3033
"signUp": "가입하기",

src/locales/ru/main.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"emailPlaceholder": "Введите вашу электронную почту",
1818
"failed": "Вход не удался",
1919
"forgotPassword": "Забыли пароль?",
20+
"forgotPasswordError": "Не удалось отправить письмо для сброса пароля",
2021
"genericErrorMessage": "Извините, произошла ошибка. Пожалуйста, свяжитесь с {supportEmail}.",
2122
"loginButton": "Войти",
2223
"loginWithGithub": "Войти через Github",
@@ -25,6 +26,8 @@
2526
"orContinueWith": "Или продолжить с",
2627
"passwordLabel": "Пароль",
2728
"passwordPlaceholder": "Введите ваш пароль",
29+
"passwordResetSent": "Письмо для сброса пароля отправлено",
30+
"passwordResetSentDetail": "Пожалуйста, проверьте свою электронную почту для получения ссылки на сброс пароля.",
2831
"privacyLink": "Политикой конфиденциальности",
2932
"signInOrSignUp": "Войти / Зарегистрироваться",
3033
"signUp": "Зарегистрироваться",

src/locales/zh/main.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"emailPlaceholder": "输入您的电子邮件",
1818
"failed": "登录失败",
1919
"forgotPassword": "忘记密码?",
20+
"forgotPasswordError": "发送重置密码邮件失败",
2021
"genericErrorMessage": "抱歉,我们遇到了一些错误。请联系 {supportEmail}。",
2122
"loginButton": "登录",
2223
"loginWithGithub": "使用Github登录",
@@ -25,6 +26,8 @@
2526
"orContinueWith": "或者继续使用",
2627
"passwordLabel": "密码",
2728
"passwordPlaceholder": "输入您的密码",
29+
"passwordResetSent": "重置密码邮件已发送",
30+
"passwordResetSentDetail": "请查收您的电子邮件,点击链接重置密码。",
2831
"privacyLink": "隐私政策",
2932
"signInOrSignUp": "登录 / 注册",
3033
"signUp": "注册",

src/stores/firebaseAuthStore.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
browserLocalPersistence,
88
createUserWithEmailAndPassword,
99
onAuthStateChanged,
10+
sendPasswordResetEmail,
1011
setPersistence,
1112
signInWithEmailAndPassword,
1213
signInWithPopup,
@@ -226,6 +227,11 @@ export const useFirebaseAuthStore = defineStore('firebaseAuth', () => {
226227
const logout = async (): Promise<void> =>
227228
executeAuthAction((authInstance) => signOut(authInstance))
228229

230+
const sendPasswordReset = async (email: string): Promise<void> =>
231+
executeAuthAction((authInstance) =>
232+
sendPasswordResetEmail(authInstance, email)
233+
)
234+
229235
const addCredits = async (
230236
requestBodyContent: CreditPurchasePayload
231237
): Promise<CreditPurchaseResponse | null> => {
@@ -329,6 +335,7 @@ export const useFirebaseAuthStore = defineStore('firebaseAuth', () => {
329335
openSignInPanel,
330336
openCreditsPanel,
331337
fetchBalance,
332-
accessBillingPortal
338+
accessBillingPortal,
339+
sendPasswordReset
333340
}
334341
})

0 commit comments

Comments
 (0)