⭐️⭐️⭐️ Open-source, self-hosted alternative to Linear and Plane. Project management and issue tracking where teams and AI agents work side by side to plan and ship products.
TypeScript agenticagileai-agentsbug-reportingbug-trackerganttissue-trackerjirajira-alternativekanbanlinearlinear-alternativeopen-sourceproduct-managementproject-managementroadmapself-hostedsprint-planningteam-collaborationtrello-alternative
fix(web): forgot-password page asks for an address with passwords off (#618)
Pasqual Troncone012c03ae85cd
diff --git a/apps/web/messages/ar/auth.json b/apps/web/messages/ar/auth.jsonindex 95aad832..f3b53c8d 100644--- a/apps/web/messages/ar/auth.json+++ b/apps/web/messages/ar/auth.json@@ -63,6 +63,7 @@"forgotPassword": {"title": "إعادة تعيين كلمة المرور","subtitle": "هنبعتلك رابط تعيّن بيه كلمة مرور جديدة",+ "subtitleSso": "كلمة مرورك تُدار من خلال مزوّد الهوية الخاص بك","submit": "إرسال رابط إعادة التعيين","submitPending": "جارٍ الإرسال…","sentTitle": "تحقّق من بريدك",diff --git a/apps/web/messages/en/auth.json b/apps/web/messages/en/auth.jsonindex ddc37bb7..588b7603 100644--- a/apps/web/messages/en/auth.json+++ b/apps/web/messages/en/auth.json@@ -63,6 +63,7 @@"forgotPassword": {"title": "Reset your password","subtitle": "We will email you a link to set a new one",+ "subtitleSso": "Your password is managed by your identity provider","submit": "Send reset link","submitPending": "Sending…","sentTitle": "Check your email",diff --git a/apps/web/messages/es-ES/auth.json b/apps/web/messages/es-ES/auth.jsonindex 437492fa..9301a0ff 100644--- a/apps/web/messages/es-ES/auth.json+++ b/apps/web/messages/es-ES/auth.json@@ -63,6 +63,7 @@"forgotPassword": {"title": "Restablecer la contraseña","subtitle": "Te enviaremos un enlace por correo para definir una nueva",+ "subtitleSso": "Tu proveedor de identidades gestiona tu contraseña","submit": "Enviar enlace de restablecimiento","submitPending": "Enviando…","sentTitle": "Revisa tu correo",diff --git a/apps/web/messages/fa/auth.json b/apps/web/messages/fa/auth.jsonindex 5845674b..a01b31b1 100644--- a/apps/web/messages/fa/auth.json+++ b/apps/web/messages/fa/auth.json@@ -63,6 +63,7 @@"forgotPassword": {"title": "بازنشانی گذرواژه","subtitle": "ما لینکی برای تنظیم گذرواژه جدید به ایمیل شما ارسال میکنیم",+ "subtitleSso": "رمز عبور شما توسط ارائهدهنده هویت شما مدیریت میشود","submit": "ارسال لینک بازنشانی","submitPending": "در حال ارسال…","sentTitle": "ایمیل خود را بررسی کنید",diff --git a/apps/web/messages/fr/auth.json b/apps/web/messages/fr/auth.jsonindex f3448de5..1afa8847 100644--- a/apps/web/messages/fr/auth.json+++ b/apps/web/messages/fr/auth.json@@ -63,6 +63,7 @@"forgotPassword": {"title": "Réinitialisez votre mot de passe","subtitle": "Nous vous enverrons par e-mail un lien pour en définir un nouveau",+ "subtitleSso": "Votre mot de passe est géré par votre fournisseur d'identité","submit": "Envoyer le lien de réinitialisation","submitPending": "Envoi…","sentTitle": "Consultez vos e-mails",diff --git a/apps/web/messages/id/auth.json b/apps/web/messages/id/auth.jsonindex b827b899..0a575252 100644--- a/apps/web/messages/id/auth.json+++ b/apps/web/messages/id/auth.json@@ -63,6 +63,7 @@"forgotPassword": {"title": "Atur ulang kata sandi Anda","subtitle": "Kami akan mengirimkan tautan ke email Anda untuk mengatur kata sandi baru",+ "subtitleSso": "Kata sandi Anda dikelola oleh penyedia identitas Anda","submit": "Kirim tautan atur ulang","submitPending": "Mengirim…","sentTitle": "Periksa email Anda",diff --git a/apps/web/messages/ko/auth.json b/apps/web/messages/ko/auth.jsonindex b4e1538a..2c206c77 100644--- a/apps/web/messages/ko/auth.json+++ b/apps/web/messages/ko/auth.json@@ -63,6 +63,7 @@"forgotPassword": {"title": "비밀번호 재설정","subtitle": "새 비밀번호를 설정할 수 있는 링크를 이메일로 보내드립니다.",+ "subtitleSso": "비밀번호는 ID 공급자에서 관리합니다","submit": "재설정 링크 전송","submitPending": "전송 중…","sentTitle": "이메일을 확인하세요",diff --git a/apps/web/messages/pt-BR/auth.json b/apps/web/messages/pt-BR/auth.jsonindex bd41025c..d78e3153 100644--- a/apps/web/messages/pt-BR/auth.json+++ b/apps/web/messages/pt-BR/auth.json@@ -63,6 +63,7 @@"forgotPassword": {"title": "Redefina sua senha","subtitle": "Enviaremos um link por e-mail para você definir uma nova",+ "subtitleSso": "Sua senha é gerenciada pelo seu provedor de identidade","submit": "Enviar link de redefinição","submitPending": "Enviando…","sentTitle": "Verifique seu e-mail",diff --git a/apps/web/messages/ru/auth.json b/apps/web/messages/ru/auth.jsonindex d2c495bb..82d67678 100644--- a/apps/web/messages/ru/auth.json+++ b/apps/web/messages/ru/auth.json@@ -63,6 +63,7 @@"forgotPassword": {"title": "Сброс пароля","subtitle": "Мы отправим на почту ссылку, чтобы задать новый",+ "subtitleSso": "Ваш пароль управляется вашим поставщиком удостоверений","submit": "Отправить ссылку","submitPending": "Отправка…","sentTitle": "Проверьте почту",diff --git a/apps/web/messages/uk/auth.json b/apps/web/messages/uk/auth.jsonindex 0a71cf13..c4cdf1e2 100644--- a/apps/web/messages/uk/auth.json+++ b/apps/web/messages/uk/auth.json@@ -63,6 +63,7 @@"forgotPassword": {"title": "Скидання пароля","subtitle": "Ми надішлемо на пошту посилання, щоб задати новий",+ "subtitleSso": "Ваш пароль керується вашим постачальником ідентифікації","submit": "Надіслати посилання","submitPending": "Надсилання…","sentTitle": "Перевірте пошту",diff --git a/apps/web/messages/zh-CN/auth.json b/apps/web/messages/zh-CN/auth.jsonindex 9abd6754..af77b1e4 100644--- a/apps/web/messages/zh-CN/auth.json+++ b/apps/web/messages/zh-CN/auth.json@@ -63,6 +63,7 @@"forgotPassword": {"title": "重置密码","subtitle": "我们会通过邮件向你发送设置新密码的链接",+ "subtitleSso": "你的密码由身份提供方管理","submit": "发送重置链接","submitPending": "正在发送…","sentTitle": "请检查邮箱",diff --git a/apps/web/src/features/auth/components/register/AuthRegisterProviders.tsx b/apps/web/src/features/auth/components/AuthRegisterProviders.tsxsimilarity index 94%rename from apps/web/src/features/auth/components/register/AuthRegisterProviders.tsxrename to apps/web/src/features/auth/components/AuthRegisterProviders.tsxindex ec9c2cb8..16234aaf 100644--- a/apps/web/src/features/auth/components/register/AuthRegisterProviders.tsx+++ b/apps/web/src/features/auth/components/AuthRegisterProviders.tsx@@ -8,7 +8,7 @@ import GoogleIcon from '@/components/common/GoogleIcon';import { useAuthConfig } from '@/services/authConfig.service';// Signing in through a provider covers sign-up too: an address without an account-// gets one, subject to the same registration mode as the form above.+// gets one, subject to the instance registration mode.export default function AuthRegisterProviders({pending,onOidc,diff --git a/apps/web/src/features/auth/components/forgot-password/AuthForgotPasswordForm.test.tsx b/apps/web/src/features/auth/components/forgot-password/AuthForgotPasswordForm.test.tsxnew file mode 100644index 00000000..e074a711--- /dev/null+++ b/apps/web/src/features/auth/components/forgot-password/AuthForgotPasswordForm.test.tsx@@ -0,0 +1,136 @@+import assert from 'node:assert/strict';+import { afterEach, beforeEach, describe, it } from 'node:test';+import { act } from 'react';+import type { Root } from 'react-dom/client';+import { QueryClient, QueryClientProvider } from '@tanstack/react-query';+import { NextIntlClientProvider } from 'next-intl';+import { AppRouterContext } from 'next/dist/shared/lib/app-router-context.shared-runtime';+import { JSDOM } from 'jsdom';+import { qk } from '@/services/queryKeys';+import auth from '../../../../../messages/en/auth.json';++// With password sign-in off the identity provider owns the password, so the recovery+// screen sends people there instead of asking for an address to mail a link to.+const replacedGlobals = [+ 'window',+ 'document',+ 'navigator',+ 'Node',+ 'Element',+ 'HTMLElement',+ 'HTMLInputElement',+ 'HTMLFormElement',+ 'SVGElement',+ 'Event',+ 'MutationObserver',+ 'getComputedStyle',+ 'requestAnimationFrame',+ 'cancelAnimationFrame',+ 'localStorage',+ 'fetch',+ 'IS_REACT_ACT_ENVIRONMENT',+] as const;++let dom: JSDOM;+let root: Root;+let client: QueryClient;+let originals: Map<string, PropertyDescriptor | undefined>;++const router = {+ push() {},+ replace() {},+ refresh() {},+ back() {},+ forward() {},+ prefetch() {},+};++async function render(config: Record<string, unknown> | null) {+ if (config) {+ client.setQueryData(qk.authConfig, {+ registration: 'invite',+ magicLink: false,+ google: false,+ oidc: true,+ oidcLabel: 'Company SSO',+ hasUsers: true,+ ...config,+ });+ }+ const { default: AuthForgotPasswordForm } = await import('./AuthForgotPasswordForm');+ await act(async () =>+ root.render(+ <AppRouterContext.Provider value={router as never}>+ <QueryClientProvider client={client}>+ <NextIntlClientProvider locale="en" messages={{ auth }} timeZone="UTC">+ <AuthForgotPasswordForm />+ </NextIntlClientProvider>+ </QueryClientProvider>+ </AppRouterContext.Provider>,+ ),+ );+}++beforeEach(async () => {+ originals = new Map(+ replacedGlobals.map((name) => [name, Object.getOwnPropertyDescriptor(globalThis, name)]),+ );+ dom = new JSDOM('<!doctype html><div id="root"></div>', {+ url: 'https://example.test/forgot-password',+ pretendToBeVisual: true,+ });+ for (const name of replacedGlobals) {+ if (name in dom.window) {+ Object.defineProperty(globalThis, name, {+ configurable: true,+ value: dom.window[name as keyof typeof dom.window],+ });+ }+ }+ Object.defineProperties(globalThis, {+ getComputedStyle: { configurable: true, value: dom.window.getComputedStyle.bind(dom.window) },+ // The config request never answers, so a test without seeded config sees it loading.+ fetch: { configurable: true, value: () => new Promise(() => {}) },+ IS_REACT_ACT_ENVIRONMENT: { configurable: true, value: true },+ });+ Object.defineProperty(window, '__ITSAPLAN_ENV__', {+ value: { apiUrl: 'https://example.test', privacyUrl: '', termsUrl: '' },+ });+ client = new QueryClient({ defaultOptions: { queries: { retry: false, staleTime: Infinity } } });+ const { createRoot } = await import('react-dom/client');+ root = createRoot(document.querySelector('#root')!);+});++afterEach(async () => {+ await act(async () => root.unmount());+ client.clear();+ dom.window.close();+ for (const [name, descriptor] of originals) {+ if (descriptor) Object.defineProperty(globalThis, name, descriptor);+ else Reflect.deleteProperty(globalThis, name);+ }+});++describe('AuthForgotPasswordForm', () => {+ it('points to the identity provider when password sign-in is off', async () => {+ await render({ emailPassword: false });++ assert.equal(document.querySelector('#email'), null);+ assert.ok(document.body.textContent?.includes(auth.forgotPassword.subtitleSso));+ assert.ok(+ [...document.querySelectorAll('button')].some((b) => b.textContent?.includes('Company SSO')),+ );+ });++ it('asks for the address when password sign-in is on', async () => {+ await render({ emailPassword: true });++ assert.ok(document.querySelector('#email'));+ });++ it('asks for the address while the config loads', async () => {+ await render(null);++ assert.ok(document.querySelector('#email'));+ });+});diff --git a/apps/web/src/features/auth/components/forgot-password/AuthForgotPasswordForm.tsx b/apps/web/src/features/auth/components/forgot-password/AuthForgotPasswordForm.tsxindex e36925d6..25440f0b 100644--- a/apps/web/src/features/auth/components/forgot-password/AuthForgotPasswordForm.tsx+++ b/apps/web/src/features/auth/components/forgot-password/AuthForgotPasswordForm.tsx@@ -8,8 +8,14 @@ import { Field, FieldDescription, FieldError, FieldGroup, FieldLabel } from '@/cimport { Input } from '@/components/ui/input';import AuthFormHeader from '../AuthFormHeader';import AuthMessagePanel from '../AuthMessagePanel';-import { sendPasswordResetEmail } from '../../services/auth.service';+import AuthRegisterProviders from '../AuthRegisterProviders';+import {+ sendPasswordResetEmail,+ signInWithGoogle,+ signInWithOidc,+} from '../../services/auth.service';import { useAuthAction } from '../../hooks/useAuthAction';+import { useAuthConfig } from '@/services/authConfig.service';// Asks for the address and mails a reset link. The answer is the same whether or not// an account exists, so this screen never tells the visitor which it was.@@ -18,6 +24,9 @@ export default function AuthForgotPasswordForm() {const [email, setEmail] = useState('');const [sent, setSent] = useState(false);const { error, pending, run } = useAuthAction();+ // The api mails no reset link while the password form is off: the identity provider+ // holds the password then.+ const passwordEnabled = useAuthConfig()?.emailPassword !== false;function onSubmit(event: FormEvent) {event.preventDefault();@@ -44,6 +53,34 @@ export default function AuthForgotPasswordForm() {);}+ if (!passwordEnabled) {+ return (+ <div className="p-6 md:p-8">+ <FieldGroup>+ <AuthFormHeader+ title={t('forgotPassword.title')}+ description={t('forgotPassword.subtitleSso')}+ />++ <AuthRegisterProviders+ pending={pending}+ onOidc={() => run(signInWithOidc, { redirect: false })}+ onGoogle={() => run(signInWithGoogle, { redirect: false })}+ />++ {error && <FieldError>{error}</FieldError>}++ <FieldDescription className="text-center">+ {t('forgotPassword.remembered')}{' '}+ <Link href="/login" className="underline underline-offset-4">+ {t('forgotPassword.signIn')}+ </Link>+ </FieldDescription>+ </FieldGroup>+ </div>+ );+ }+return (<form onSubmit={onSubmit} className="p-6 md:p-8"><FieldGroup>diff --git a/apps/web/src/features/auth/components/register/AuthRegisterForm.tsx b/apps/web/src/features/auth/components/register/AuthRegisterForm.tsxindex ac241b36..2018c345 100644--- a/apps/web/src/features/auth/components/register/AuthRegisterForm.tsx+++ b/apps/web/src/features/auth/components/register/AuthRegisterForm.tsx@@ -14,7 +14,7 @@ import {import AuthFormHeader from '../AuthFormHeader';import AuthMessagePanel from '../AuthMessagePanel';import AuthRegisterPasswordFields from './AuthRegisterPasswordFields';-import AuthRegisterProviders from './AuthRegisterProviders';+import AuthRegisterProviders from '../AuthRegisterProviders';import { signInWithGoogle, signInWithOidc, signUpWithEmail } from '../../services/auth.service';import { useAuthAction } from '../../hooks/useAuthAction';import { useAuthConfig } from '@/services/authConfig.service';