@open-mercato/core 0.11.1-develop.8545.1.dd603570fd → 0.11.1-develop.8556.1.d944a8493f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +1 -1
- package/dist/modules/customer_accounts/api/admin/users/[id]/verify-email.js +10 -30
- package/dist/modules/customer_accounts/api/admin/users/[id]/verify-email.js.map +2 -2
- package/dist/modules/customer_accounts/api/email/verify.js +11 -10
- package/dist/modules/customer_accounts/api/email/verify.js.map +2 -2
- package/dist/modules/customer_accounts/api/magic-link/verify.js +9 -8
- package/dist/modules/customer_accounts/api/magic-link/verify.js.map +2 -2
- package/dist/modules/customer_accounts/api/password/reset-confirm.js +13 -16
- package/dist/modules/customer_accounts/api/password/reset-confirm.js.map +2 -2
- package/dist/modules/customer_accounts/api/signup.js +33 -19
- package/dist/modules/customer_accounts/api/signup.js.map +3 -3
- package/dist/modules/customer_accounts/data/validators.js +3 -2
- package/dist/modules/customer_accounts/data/validators.js.map +2 -2
- package/dist/modules/customer_accounts/lib/customerAuth.js +11 -10
- package/dist/modules/customer_accounts/lib/customerAuth.js.map +2 -2
- package/dist/modules/customer_accounts/lib/customerAuthServer.js +7 -7
- package/dist/modules/customer_accounts/lib/customerAuthServer.js.map +2 -2
- package/dist/modules/customer_accounts/lib/pendingSignup.js +16 -0
- package/dist/modules/customer_accounts/lib/pendingSignup.js.map +7 -0
- package/dist/modules/customer_accounts/lib/verifyCustomerEmail.js +50 -0
- package/dist/modules/customer_accounts/lib/verifyCustomerEmail.js.map +7 -0
- package/dist/modules/customer_accounts/services/customerInvitationService.js +15 -1
- package/dist/modules/customer_accounts/services/customerInvitationService.js.map +2 -2
- package/dist/modules/customer_accounts/services/customerTokenService.js +13 -13
- package/dist/modules/customer_accounts/services/customerTokenService.js.map +2 -2
- package/dist/modules/customer_accounts/services/customerUserService.js +1 -1
- package/dist/modules/customer_accounts/services/customerUserService.js.map +2 -2
- package/dist/modules/customer_accounts/subscribers/autoLinkCrm.js +44 -51
- package/dist/modules/customer_accounts/subscribers/autoLinkCrm.js.map +2 -2
- package/dist/modules/customer_accounts/subscribers/autoLinkCrmOnVerification.js +12 -0
- package/dist/modules/customer_accounts/subscribers/autoLinkCrmOnVerification.js.map +7 -0
- package/dist/modules/customer_accounts/subscribers/autoLinkCrmReverse.js +3 -1
- package/dist/modules/customer_accounts/subscribers/autoLinkCrmReverse.js.map +2 -2
- package/dist/modules/customer_accounts/workers/cleanupExpiredTokens.js +6 -0
- package/dist/modules/customer_accounts/workers/cleanupExpiredTokens.js.map +2 -2
- package/dist/modules/customers/commands/companies.js +8 -6
- package/dist/modules/customers/commands/companies.js.map +2 -2
- package/dist/modules/customers/commands/deals.js +24 -13
- package/dist/modules/customers/commands/deals.js.map +2 -2
- package/dist/modules/customers/commands/people.js +8 -6
- package/dist/modules/customers/commands/people.js.map +2 -2
- package/dist/modules/entities/lib/helpers.js +6 -2
- package/dist/modules/entities/lib/helpers.js.map +2 -2
- package/dist/modules/portal/frontend/[orgSlug]/portal/PasswordForm.js +127 -0
- package/dist/modules/portal/frontend/[orgSlug]/portal/PasswordForm.js.map +7 -0
- package/dist/modules/portal/frontend/[orgSlug]/portal/reset-password/page.js +10 -122
- package/dist/modules/portal/frontend/[orgSlug]/portal/reset-password/page.js.map +2 -2
- package/dist/modules/portal/frontend/[orgSlug]/portal/signup/page.js +2 -11
- package/dist/modules/portal/frontend/[orgSlug]/portal/signup/page.js.map +2 -2
- package/dist/modules/portal/frontend/[orgSlug]/portal/verify/page.js +3 -61
- package/dist/modules/portal/frontend/[orgSlug]/portal/verify/page.js.map +2 -2
- package/package.json +8 -8
- package/src/modules/customer_accounts/api/admin/users/[id]/verify-email.ts +11 -33
- package/src/modules/customer_accounts/api/email/verify.ts +15 -11
- package/src/modules/customer_accounts/api/magic-link/verify.ts +9 -9
- package/src/modules/customer_accounts/api/password/reset-confirm.ts +13 -18
- package/src/modules/customer_accounts/api/signup.ts +36 -24
- package/src/modules/customer_accounts/data/validators.ts +2 -1
- package/src/modules/customer_accounts/lib/customerAuth.ts +12 -10
- package/src/modules/customer_accounts/lib/customerAuthServer.ts +7 -7
- package/src/modules/customer_accounts/lib/pendingSignup.ts +12 -0
- package/src/modules/customer_accounts/lib/verifyCustomerEmail.ts +57 -0
- package/src/modules/customer_accounts/services/customerInvitationService.ts +16 -1
- package/src/modules/customer_accounts/services/customerTokenService.ts +13 -13
- package/src/modules/customer_accounts/services/customerUserService.ts +2 -2
- package/src/modules/customer_accounts/subscribers/autoLinkCrm.ts +46 -78
- package/src/modules/customer_accounts/subscribers/autoLinkCrmOnVerification.ts +9 -0
- package/src/modules/customer_accounts/subscribers/autoLinkCrmReverse.ts +3 -1
- package/src/modules/customer_accounts/workers/cleanupExpiredTokens.ts +7 -0
- package/src/modules/customers/commands/companies.ts +7 -5
- package/src/modules/customers/commands/deals.ts +22 -12
- package/src/modules/customers/commands/people.ts +7 -4
- package/src/modules/entities/lib/helpers.ts +8 -2
- package/src/modules/portal/frontend/[orgSlug]/portal/PasswordForm.tsx +182 -0
- package/src/modules/portal/frontend/[orgSlug]/portal/reset-password/page.tsx +9 -165
- package/src/modules/portal/frontend/[orgSlug]/portal/signup/page.tsx +2 -12
- package/src/modules/portal/frontend/[orgSlug]/portal/verify/page.tsx +3 -89
- package/src/modules/portal/i18n/de.json +2 -1
- package/src/modules/portal/i18n/en.json +2 -1
- package/src/modules/portal/i18n/es.json +2 -1
- package/src/modules/portal/i18n/ko.json +2 -1
- package/src/modules/portal/i18n/pl.json +2 -1
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
import { useCallback, useState, useEffect, type ReactNode } from 'react'
|
|
3
|
+
import { useSearchParams } from 'next/navigation'
|
|
4
|
+
import Link from 'next/link'
|
|
5
|
+
import { useT } from '@open-mercato/shared/lib/i18n/context'
|
|
6
|
+
import { PasswordInput } from '@open-mercato/ui/primitives/password-input'
|
|
7
|
+
import { Label } from '@open-mercato/ui/primitives/label'
|
|
8
|
+
import { Button } from '@open-mercato/ui/primitives/button'
|
|
9
|
+
import { Alert, AlertDescription } from '@open-mercato/ui/primitives/alert'
|
|
10
|
+
import { EmptyState } from '@open-mercato/ui/primitives/empty-state'
|
|
11
|
+
import { SearchX } from 'lucide-react'
|
|
12
|
+
import { Spinner } from '@open-mercato/ui/primitives/spinner'
|
|
13
|
+
import { apiCall } from '@open-mercato/ui/backend/utils/apiCall'
|
|
14
|
+
import { usePortalContext } from '@open-mercato/ui/portal/PortalContext'
|
|
15
|
+
|
|
16
|
+
type Props = {
|
|
17
|
+
params: { orgSlug: string }
|
|
18
|
+
verify?: boolean
|
|
19
|
+
beforeForm?: ReactNode
|
|
20
|
+
afterForm?: ReactNode
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function PortalPasswordForm({ params, verify = false, beforeForm, afterForm }: Props) {
|
|
24
|
+
const t = useT()
|
|
25
|
+
const orgSlug = params.orgSlug
|
|
26
|
+
const { tenant } = usePortalContext()
|
|
27
|
+
const searchParams = useSearchParams()
|
|
28
|
+
|
|
29
|
+
const [password, setPassword] = useState('')
|
|
30
|
+
const [confirmPassword, setConfirmPassword] = useState('')
|
|
31
|
+
const [error, setError] = useState<string | null>(null)
|
|
32
|
+
const [success, setSuccess] = useState(false)
|
|
33
|
+
const [submitting, setSubmitting] = useState(false)
|
|
34
|
+
const token = searchParams.get('token')
|
|
35
|
+
const noTokenMessage = verify
|
|
36
|
+
? t('portal.verify.error.invalidToken', 'Verification token is missing.')
|
|
37
|
+
: t('portal.resetPassword.error.noToken', 'Invalid or missing reset token.')
|
|
38
|
+
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
if (!token) setError(noTokenMessage)
|
|
41
|
+
}, [token, noTokenMessage])
|
|
42
|
+
|
|
43
|
+
const handleSubmit = useCallback(
|
|
44
|
+
async (event: React.FormEvent) => {
|
|
45
|
+
event.preventDefault()
|
|
46
|
+
setError(null)
|
|
47
|
+
|
|
48
|
+
if (!token) {
|
|
49
|
+
setError(noTokenMessage)
|
|
50
|
+
return
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (password !== confirmPassword) {
|
|
54
|
+
setError(t('portal.resetPassword.error.passwordMismatch', 'Passwords do not match.'))
|
|
55
|
+
return
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (password.length < 8) {
|
|
59
|
+
setError(t('portal.resetPassword.error.passwordTooShort', 'Password must be at least 8 characters long.'))
|
|
60
|
+
return
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
setSubmitting(true)
|
|
64
|
+
try {
|
|
65
|
+
const endpoint = verify ? '/api/customer_accounts/email/verify' : '/api/customer_accounts/password/reset-confirm'
|
|
66
|
+
const result = await apiCall<{ ok: boolean; error?: string }>(endpoint, {
|
|
67
|
+
method: 'POST',
|
|
68
|
+
headers: { 'Content-Type': 'application/json' },
|
|
69
|
+
body: JSON.stringify({ token, password }),
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
if (result.ok && result.result?.ok) {
|
|
73
|
+
setSuccess(true)
|
|
74
|
+
return
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (verify) {
|
|
78
|
+
setError(t('portal.verify.error.generic', 'Email verification failed. Please try again.'))
|
|
79
|
+
} else if (result.status === 400) {
|
|
80
|
+
setError(t('portal.resetPassword.error.invalidToken', 'Invalid or expired reset token.'))
|
|
81
|
+
} else {
|
|
82
|
+
setError(result.result?.error || t('portal.resetPassword.error.generic', 'Password reset failed. Please try again.'))
|
|
83
|
+
}
|
|
84
|
+
} catch {
|
|
85
|
+
setError(verify
|
|
86
|
+
? t('portal.verify.error.generic', 'Email verification failed. Please try again.')
|
|
87
|
+
: t('portal.resetPassword.error.generic', 'Password reset failed. Please try again.'))
|
|
88
|
+
} finally {
|
|
89
|
+
setSubmitting(false)
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
[token, password, confirmPassword, t, verify, noTokenMessage],
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
if (tenant.loading) {
|
|
96
|
+
return <div className="flex items-center justify-center py-20"><Spinner /></div>
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (tenant.error) {
|
|
100
|
+
return (
|
|
101
|
+
<div className="mx-auto w-full max-w-md py-12">
|
|
102
|
+
<EmptyState
|
|
103
|
+
variant="subtle"
|
|
104
|
+
size="lg"
|
|
105
|
+
icon={<SearchX className="h-6 w-6" aria-hidden />}
|
|
106
|
+
title={t('portal.org.invalid', 'Organization not found.')}
|
|
107
|
+
/>
|
|
108
|
+
</div>
|
|
109
|
+
)
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (success) {
|
|
113
|
+
return (
|
|
114
|
+
<div className="mx-auto w-full max-w-sm">
|
|
115
|
+
<div className="mb-8 text-center">
|
|
116
|
+
<h1 className="text-2xl font-bold tracking-tight">{verify
|
|
117
|
+
? t('portal.verify.success.title', 'Email verified')
|
|
118
|
+
: t('portal.resetPassword.success.title', 'Password Reset Complete')}</h1>
|
|
119
|
+
<p className="mt-1.5 text-sm text-muted-foreground">{verify
|
|
120
|
+
? t('portal.verify.success.description', 'Your email has been verified. You can now sign in to the portal.')
|
|
121
|
+
: t('portal.resetPassword.success.description', 'Your password has been successfully reset.')}</p>
|
|
122
|
+
</div>
|
|
123
|
+
|
|
124
|
+
<Alert>
|
|
125
|
+
<AlertDescription>{t('portal.resetPassword.success.message', 'You can now sign in with your new password.')}</AlertDescription>
|
|
126
|
+
</Alert>
|
|
127
|
+
|
|
128
|
+
<div className="mt-6 text-center">
|
|
129
|
+
<Link href={`/${orgSlug}/portal/login`} className="font-medium text-foreground underline underline-offset-4 hover:opacity-80">
|
|
130
|
+
{t('portal.resetPassword.success.loginLink', 'Go to Sign In')}
|
|
131
|
+
</Link>
|
|
132
|
+
</div>
|
|
133
|
+
</div>
|
|
134
|
+
)
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
return (
|
|
138
|
+
<div className="mx-auto w-full max-w-sm">
|
|
139
|
+
<div className="mb-8 text-center">
|
|
140
|
+
<h1 className="text-2xl font-bold tracking-tight">{verify
|
|
141
|
+
? t('portal.verify.title', 'Verify email')
|
|
142
|
+
: t('portal.resetPassword.title', 'Reset Password')}</h1>
|
|
143
|
+
<p className="mt-1.5 text-sm text-muted-foreground">{t('portal.resetPassword.description', 'Enter your new password below.')}</p>
|
|
144
|
+
</div>
|
|
145
|
+
|
|
146
|
+
{beforeForm}
|
|
147
|
+
|
|
148
|
+
<form onSubmit={handleSubmit} className="flex flex-col gap-4">
|
|
149
|
+
{error ? (
|
|
150
|
+
<Alert status="error">
|
|
151
|
+
<AlertDescription>{error}</AlertDescription>
|
|
152
|
+
</Alert>
|
|
153
|
+
) : null}
|
|
154
|
+
|
|
155
|
+
<div className="flex flex-col gap-1.5">
|
|
156
|
+
<Label htmlFor="reset-password" className="text-overline font-semibold uppercase tracking-wider text-muted-foreground/70">{t('portal.resetPassword.password', 'New Password')}</Label>
|
|
157
|
+
<PasswordInput id="reset-password" autoComplete="new-password" required placeholder={t('portal.resetPassword.password.placeholder', '••••••••')} value={password} onChange={(e) => setPassword(e.target.value)} disabled={submitting || !token} className="rounded-lg" />
|
|
158
|
+
</div>
|
|
159
|
+
|
|
160
|
+
<div className="flex flex-col gap-1.5">
|
|
161
|
+
<Label htmlFor="confirm-password" className="text-overline font-semibold uppercase tracking-wider text-muted-foreground/70">{t('portal.resetPassword.confirmPassword', 'Confirm New Password')}</Label>
|
|
162
|
+
<PasswordInput id="confirm-password" autoComplete="new-password" required placeholder={t('portal.resetPassword.confirmPassword.placeholder', '••••••••')} value={confirmPassword} onChange={(e) => setConfirmPassword(e.target.value)} disabled={submitting || !token} className="rounded-lg" />
|
|
163
|
+
</div>
|
|
164
|
+
|
|
165
|
+
<Button type="submit" disabled={submitting || !token} className="mt-1 w-full rounded-lg">
|
|
166
|
+
{verify
|
|
167
|
+
? t('portal.verify.submit', 'Verify email and set password')
|
|
168
|
+
: submitting ? t('portal.resetPassword.submitting', 'Resetting password...') : t('portal.resetPassword.submit', 'Reset Password')}
|
|
169
|
+
</Button>
|
|
170
|
+
|
|
171
|
+
<p className="text-center text-sm text-muted-foreground">
|
|
172
|
+
{verify ? null : t('portal.resetPassword.backToLogin', 'Remember your password?')}{' '}
|
|
173
|
+
<Link href={`/${orgSlug}/portal/login`} className="font-medium text-foreground underline underline-offset-4 hover:opacity-80">
|
|
174
|
+
{t('portal.resetPassword.loginLink', 'Sign in')}
|
|
175
|
+
</Link>
|
|
176
|
+
</p>
|
|
177
|
+
</form>
|
|
178
|
+
|
|
179
|
+
{afterForm}
|
|
180
|
+
</div>
|
|
181
|
+
)
|
|
182
|
+
}
|
|
@@ -1,173 +1,17 @@
|
|
|
1
1
|
"use client"
|
|
2
|
-
import {
|
|
2
|
+
import { useMemo } from 'react'
|
|
3
3
|
import { extensionPoints } from '@open-mercato/core/modules/portal/extension-points'
|
|
4
|
-
import { useSearchParams } from 'next/navigation'
|
|
5
|
-
import Link from 'next/link'
|
|
6
|
-
import { useT } from '@open-mercato/shared/lib/i18n/context'
|
|
7
|
-
import { PasswordInput } from '@open-mercato/ui/primitives/password-input'
|
|
8
|
-
import { Label } from '@open-mercato/ui/primitives/label'
|
|
9
|
-
import { Button } from '@open-mercato/ui/primitives/button'
|
|
10
|
-
import { Alert, AlertDescription } from '@open-mercato/ui/primitives/alert'
|
|
11
|
-
import { EmptyState } from '@open-mercato/ui/primitives/empty-state'
|
|
12
|
-
import { SearchX } from 'lucide-react'
|
|
13
|
-
import { Spinner } from '@open-mercato/ui/primitives/spinner'
|
|
14
|
-
import { apiCall } from '@open-mercato/ui/backend/utils/apiCall'
|
|
15
|
-
import { usePortalContext } from '@open-mercato/ui/portal/PortalContext'
|
|
16
4
|
import { InjectionSpot } from '@open-mercato/ui/backend/injection/InjectionSpot'
|
|
5
|
+
import { PortalPasswordForm } from '../PasswordForm'
|
|
17
6
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
export default function PortalResetPasswordPage({ params }: Props) {
|
|
21
|
-
const t = useT()
|
|
7
|
+
export default function PortalResetPasswordPage({ params }: { params: { orgSlug: string } }) {
|
|
22
8
|
const orgSlug = params.orgSlug
|
|
23
|
-
const
|
|
24
|
-
const searchParams = useSearchParams()
|
|
25
|
-
|
|
26
|
-
const [password, setPassword] = useState('')
|
|
27
|
-
const [confirmPassword, setConfirmPassword] = useState('')
|
|
28
|
-
const [error, setError] = useState<string | null>(null)
|
|
29
|
-
const [success, setSuccess] = useState(false)
|
|
30
|
-
const [submitting, setSubmitting] = useState(false)
|
|
31
|
-
const [token, setToken] = useState<string | null>(null)
|
|
32
|
-
|
|
33
|
-
useEffect(() => {
|
|
34
|
-
const tokenParam = searchParams.get('token')
|
|
35
|
-
if (!tokenParam) {
|
|
36
|
-
setError(t('portal.resetPassword.error.noToken', 'Invalid or missing reset token.'))
|
|
37
|
-
} else {
|
|
38
|
-
setToken(tokenParam)
|
|
39
|
-
}
|
|
40
|
-
}, [searchParams, t])
|
|
41
|
-
|
|
42
|
-
const handleSubmit = useCallback(
|
|
43
|
-
async (event: React.FormEvent) => {
|
|
44
|
-
event.preventDefault()
|
|
45
|
-
setError(null)
|
|
46
|
-
|
|
47
|
-
if (!token) {
|
|
48
|
-
setError(t('portal.resetPassword.error.noToken', 'Invalid or missing reset token.'))
|
|
49
|
-
return
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
if (password !== confirmPassword) {
|
|
53
|
-
setError(t('portal.resetPassword.error.passwordMismatch', 'Passwords do not match.'))
|
|
54
|
-
return
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if (password.length < 8) {
|
|
58
|
-
setError(t('portal.resetPassword.error.passwordTooShort', 'Password must be at least 8 characters long.'))
|
|
59
|
-
return
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
setSubmitting(true)
|
|
63
|
-
try {
|
|
64
|
-
const result = await apiCall<{ ok: boolean; error?: string }>('/api/customer_accounts/password/reset-confirm', {
|
|
65
|
-
method: 'POST',
|
|
66
|
-
headers: { 'Content-Type': 'application/json' },
|
|
67
|
-
body: JSON.stringify({ token, password }),
|
|
68
|
-
})
|
|
69
|
-
|
|
70
|
-
if (result.ok && result.result?.ok) {
|
|
71
|
-
setSuccess(true)
|
|
72
|
-
return
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
if (result.status === 400) {
|
|
76
|
-
setError(t('portal.resetPassword.error.invalidToken', 'Invalid or expired reset token.'))
|
|
77
|
-
} else {
|
|
78
|
-
setError(result.result?.error || t('portal.resetPassword.error.generic', 'Password reset failed. Please try again.'))
|
|
79
|
-
}
|
|
80
|
-
} catch {
|
|
81
|
-
setError(t('portal.resetPassword.error.generic', 'Password reset failed. Please try again.'))
|
|
82
|
-
} finally {
|
|
83
|
-
setSubmitting(false)
|
|
84
|
-
}
|
|
85
|
-
},
|
|
86
|
-
[token, password, confirmPassword, t],
|
|
87
|
-
)
|
|
88
|
-
|
|
89
|
-
const injectionContext = useMemo(
|
|
90
|
-
() => ({ orgSlug }),
|
|
91
|
-
[orgSlug],
|
|
92
|
-
)
|
|
93
|
-
|
|
94
|
-
if (tenant.loading) {
|
|
95
|
-
return <div className="flex items-center justify-center py-20"><Spinner /></div>
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
if (tenant.error) {
|
|
99
|
-
return (
|
|
100
|
-
<div className="mx-auto w-full max-w-md py-12">
|
|
101
|
-
<EmptyState
|
|
102
|
-
variant="subtle"
|
|
103
|
-
size="lg"
|
|
104
|
-
icon={<SearchX className="h-6 w-6" aria-hidden />}
|
|
105
|
-
title={t('portal.org.invalid', 'Organization not found.')}
|
|
106
|
-
/>
|
|
107
|
-
</div>
|
|
108
|
-
)
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
if (success) {
|
|
112
|
-
return (
|
|
113
|
-
<div className="mx-auto w-full max-w-sm">
|
|
114
|
-
<div className="mb-8 text-center">
|
|
115
|
-
<h1 className="text-2xl font-bold tracking-tight">{t('portal.resetPassword.success.title', 'Password Reset Complete')}</h1>
|
|
116
|
-
<p className="mt-1.5 text-sm text-muted-foreground">{t('portal.resetPassword.success.description', 'Your password has been successfully reset.')}</p>
|
|
117
|
-
</div>
|
|
118
|
-
|
|
119
|
-
<Alert>
|
|
120
|
-
<AlertDescription>{t('portal.resetPassword.success.message', 'You can now sign in with your new password.')}</AlertDescription>
|
|
121
|
-
</Alert>
|
|
122
|
-
|
|
123
|
-
<div className="mt-6 text-center">
|
|
124
|
-
<Link href={`/${orgSlug}/portal/login`} className="font-medium text-foreground underline underline-offset-4 hover:opacity-80">
|
|
125
|
-
{t('portal.resetPassword.success.loginLink', 'Go to Sign In')}
|
|
126
|
-
</Link>
|
|
127
|
-
</div>
|
|
128
|
-
</div>
|
|
129
|
-
)
|
|
130
|
-
}
|
|
131
|
-
|
|
9
|
+
const injectionContext = useMemo(() => ({ orgSlug }), [orgSlug])
|
|
132
10
|
return (
|
|
133
|
-
<
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
<InjectionSpot spotId={extensionPoints.hosts.resetPasswordBefore.spotId} context={injectionContext} />
|
|
140
|
-
|
|
141
|
-
<form onSubmit={handleSubmit} className="flex flex-col gap-4">
|
|
142
|
-
{error ? (
|
|
143
|
-
<Alert status="error">
|
|
144
|
-
<AlertDescription>{error}</AlertDescription>
|
|
145
|
-
</Alert>
|
|
146
|
-
) : null}
|
|
147
|
-
|
|
148
|
-
<div className="flex flex-col gap-1.5">
|
|
149
|
-
<Label htmlFor="reset-password" className="text-overline font-semibold uppercase tracking-wider text-muted-foreground/70">{t('portal.resetPassword.password', 'New Password')}</Label>
|
|
150
|
-
<PasswordInput id="reset-password" autoComplete="new-password" required placeholder={t('portal.resetPassword.password.placeholder', '••••••••')} value={password} onChange={(e) => setPassword(e.target.value)} disabled={submitting || !token} className="rounded-lg" />
|
|
151
|
-
</div>
|
|
152
|
-
|
|
153
|
-
<div className="flex flex-col gap-1.5">
|
|
154
|
-
<Label htmlFor="confirm-password" className="text-overline font-semibold uppercase tracking-wider text-muted-foreground/70">{t('portal.resetPassword.confirmPassword', 'Confirm New Password')}</Label>
|
|
155
|
-
<PasswordInput id="confirm-password" autoComplete="new-password" required placeholder={t('portal.resetPassword.confirmPassword.placeholder', '••••••••')} value={confirmPassword} onChange={(e) => setConfirmPassword(e.target.value)} disabled={submitting || !token} className="rounded-lg" />
|
|
156
|
-
</div>
|
|
157
|
-
|
|
158
|
-
<Button type="submit" disabled={submitting || !token} className="mt-1 w-full rounded-lg">
|
|
159
|
-
{submitting ? t('portal.resetPassword.submitting', 'Resetting password...') : t('portal.resetPassword.submit', 'Reset Password')}
|
|
160
|
-
</Button>
|
|
161
|
-
|
|
162
|
-
<p className="text-center text-sm text-muted-foreground">
|
|
163
|
-
{t('portal.resetPassword.backToLogin', 'Remember your password?')}{' '}
|
|
164
|
-
<Link href={`/${orgSlug}/portal/login`} className="font-medium text-foreground underline underline-offset-4 hover:opacity-80">
|
|
165
|
-
{t('portal.resetPassword.loginLink', 'Sign in')}
|
|
166
|
-
</Link>
|
|
167
|
-
</p>
|
|
168
|
-
</form>
|
|
169
|
-
|
|
170
|
-
<InjectionSpot spotId={extensionPoints.hosts.resetPasswordAfter.spotId} context={injectionContext} />
|
|
171
|
-
</div>
|
|
11
|
+
<PortalPasswordForm
|
|
12
|
+
params={params}
|
|
13
|
+
beforeForm={<InjectionSpot spotId={extensionPoints.hosts.resetPasswordBefore.spotId} context={injectionContext} />}
|
|
14
|
+
afterForm={<InjectionSpot spotId={extensionPoints.hosts.resetPasswordAfter.spotId} context={injectionContext} />}
|
|
15
|
+
/>
|
|
172
16
|
)
|
|
173
17
|
}
|
|
@@ -5,7 +5,6 @@ import Link from 'next/link'
|
|
|
5
5
|
import { useT } from '@open-mercato/shared/lib/i18n/context'
|
|
6
6
|
import { Input } from '@open-mercato/ui/primitives/input'
|
|
7
7
|
import { EmailInput } from '@open-mercato/ui/primitives/email-input'
|
|
8
|
-
import { PasswordInput } from '@open-mercato/ui/primitives/password-input'
|
|
9
8
|
import { Label } from '@open-mercato/ui/primitives/label'
|
|
10
9
|
import { Button } from '@open-mercato/ui/primitives/button'
|
|
11
10
|
import { Alert, AlertDescription } from '@open-mercato/ui/primitives/alert'
|
|
@@ -26,7 +25,6 @@ export default function PortalSignupPage({ params }: Props) {
|
|
|
26
25
|
|
|
27
26
|
const [displayName, setDisplayName] = useState('')
|
|
28
27
|
const [email, setEmail] = useState('')
|
|
29
|
-
const [password, setPassword] = useState('')
|
|
30
28
|
const [error, setError] = useState<string | null>(null)
|
|
31
29
|
const [fieldErrors, setFieldErrors] = useState<Record<string, string>>({})
|
|
32
30
|
const [success, setSuccess] = useState(false)
|
|
@@ -48,7 +46,7 @@ export default function PortalSignupPage({ params }: Props) {
|
|
|
48
46
|
const result = await apiCall<SignupResponse>('/api/customer_accounts/signup', {
|
|
49
47
|
method: 'POST',
|
|
50
48
|
headers: { 'Content-Type': 'application/json' },
|
|
51
|
-
body: JSON.stringify({ email,
|
|
49
|
+
body: JSON.stringify({ email, displayName, organizationId: tenant.organizationId }),
|
|
52
50
|
})
|
|
53
51
|
|
|
54
52
|
if (result.status === 202 && result.result?.ok) {
|
|
@@ -66,8 +64,6 @@ export default function PortalSignupPage({ params }: Props) {
|
|
|
66
64
|
mapped.displayName = t('portal.signup.error.displayName.required', 'Full name is required.')
|
|
67
65
|
} else if (fieldKey === 'email') {
|
|
68
66
|
mapped.email = t('portal.signup.error.email.invalid', 'Please enter a valid email address.')
|
|
69
|
-
} else if (fieldKey === 'password') {
|
|
70
|
-
mapped.password = t('portal.signup.error.password.minLength', 'Password must be at least 8 characters.')
|
|
71
67
|
}
|
|
72
68
|
}
|
|
73
69
|
const hasUnmappedField = detailEntries.some(([fieldKey]) => !(fieldKey in mapped))
|
|
@@ -84,7 +80,7 @@ export default function PortalSignupPage({ params }: Props) {
|
|
|
84
80
|
setSubmitting(false)
|
|
85
81
|
}
|
|
86
82
|
},
|
|
87
|
-
[displayName, email,
|
|
83
|
+
[displayName, email, tenant.organizationId, t],
|
|
88
84
|
)
|
|
89
85
|
|
|
90
86
|
const injectionContext = useMemo(
|
|
@@ -155,12 +151,6 @@ export default function PortalSignupPage({ params }: Props) {
|
|
|
155
151
|
{fieldErrors.email && <p id="signup-email-error" role="alert" className="text-sm text-destructive">{fieldErrors.email}</p>}
|
|
156
152
|
</div>
|
|
157
153
|
|
|
158
|
-
<div className="flex flex-col gap-1.5">
|
|
159
|
-
<Label htmlFor="signup-password" className="text-overline font-semibold uppercase tracking-wider text-muted-foreground/70">{t('portal.signup.password', 'Password')}</Label>
|
|
160
|
-
<PasswordInput id="signup-password" autoComplete="new-password" required placeholder={t('portal.signup.password.placeholder', '\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022')} value={password} onChange={(e) => setPassword(e.target.value)} disabled={submitting} aria-invalid={fieldErrors.password ? true : undefined} aria-describedby={fieldErrors.password ? 'signup-password-error' : undefined} className="rounded-lg" />
|
|
161
|
-
{fieldErrors.password && <p id="signup-password-error" role="alert" className="text-sm text-destructive">{fieldErrors.password}</p>}
|
|
162
|
-
</div>
|
|
163
|
-
|
|
164
154
|
<Button type="submit" disabled={submitting} className="mt-1 w-full rounded-lg">
|
|
165
155
|
{submitting ? t('portal.signup.submitting', 'Creating account...') : t('portal.signup.submit', 'Create Account')}
|
|
166
156
|
</Button>
|
|
@@ -1,92 +1,6 @@
|
|
|
1
1
|
"use client"
|
|
2
|
-
import {
|
|
3
|
-
import Link from 'next/link'
|
|
4
|
-
import { useSearchParams } from 'next/navigation'
|
|
5
|
-
import { useT } from '@open-mercato/shared/lib/i18n/context'
|
|
6
|
-
import { apiCall } from '@open-mercato/ui/backend/utils/apiCall'
|
|
7
|
-
import { Button } from '@open-mercato/ui/primitives/button'
|
|
8
|
-
import { Alert, AlertDescription } from '@open-mercato/ui/primitives/alert'
|
|
9
|
-
import { Spinner } from '@open-mercato/ui/primitives/spinner'
|
|
2
|
+
import { PortalPasswordForm } from '../PasswordForm'
|
|
10
3
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
type VerifyState = 'verifying' | 'success' | 'error'
|
|
14
|
-
|
|
15
|
-
export default function PortalVerifyPage({ params }: Props) {
|
|
16
|
-
const t = useT()
|
|
17
|
-
const searchParams = useSearchParams()
|
|
18
|
-
const token = searchParams.get('token') ?? ''
|
|
19
|
-
const [state, setState] = useState<VerifyState>(token ? 'verifying' : 'error')
|
|
20
|
-
const [error, setError] = useState<string | null>(token ? null : t('portal.verify.error.invalidToken', 'Verification token is missing.'))
|
|
21
|
-
|
|
22
|
-
useEffect(() => {
|
|
23
|
-
if (!token) return
|
|
24
|
-
|
|
25
|
-
let active = true
|
|
26
|
-
|
|
27
|
-
void apiCall<{ ok: boolean; error?: string }>('/api/customer_accounts/email/verify', {
|
|
28
|
-
method: 'POST',
|
|
29
|
-
headers: { 'Content-Type': 'application/json' },
|
|
30
|
-
body: JSON.stringify({ token }),
|
|
31
|
-
}).then((result) => {
|
|
32
|
-
if (!active) return
|
|
33
|
-
if (result.ok && result.result?.ok) {
|
|
34
|
-
setState('success')
|
|
35
|
-
return
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
setState('error')
|
|
39
|
-
setError(result.result?.error || t('portal.verify.error.generic', 'Email verification failed. Please try again.'))
|
|
40
|
-
}).catch(() => {
|
|
41
|
-
if (!active) return
|
|
42
|
-
setState('error')
|
|
43
|
-
setError(t('portal.verify.error.generic', 'Email verification failed. Please try again.'))
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
return () => {
|
|
47
|
-
active = false
|
|
48
|
-
}
|
|
49
|
-
}, [token, t])
|
|
50
|
-
|
|
51
|
-
if (state === 'verifying') {
|
|
52
|
-
return (
|
|
53
|
-
<div className="mx-auto flex max-w-sm flex-col items-center gap-4 py-12 text-center">
|
|
54
|
-
<Spinner />
|
|
55
|
-
<div>
|
|
56
|
-
<h1 className="text-2xl font-bold tracking-tight">{t('portal.verify.title', 'Verifying email')}</h1>
|
|
57
|
-
<p className="mt-1.5 text-sm text-muted-foreground">{t('portal.verify.description', 'Please wait while we verify your email address.')}</p>
|
|
58
|
-
</div>
|
|
59
|
-
</div>
|
|
60
|
-
)
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
if (state === 'success') {
|
|
64
|
-
return (
|
|
65
|
-
<div className="mx-auto flex max-w-sm flex-col items-center gap-4 py-12 text-center">
|
|
66
|
-
<div className="mx-auto flex size-12 items-center justify-center rounded-full bg-foreground text-background">
|
|
67
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" className="size-6">
|
|
68
|
-
<polyline points="20 6 9 17 4 12" />
|
|
69
|
-
</svg>
|
|
70
|
-
</div>
|
|
71
|
-
<div>
|
|
72
|
-
<h1 className="text-2xl font-bold tracking-tight">{t('portal.verify.success.title', 'Email verified')}</h1>
|
|
73
|
-
<p className="mt-1.5 text-sm text-muted-foreground">{t('portal.verify.success.description', 'Your email has been verified. You can now sign in to the portal.')}</p>
|
|
74
|
-
</div>
|
|
75
|
-
<Button asChild className="w-full rounded-lg">
|
|
76
|
-
<Link href={`/${params.orgSlug}/portal/login`}>{t('portal.verify.success.loginLink', 'Sign In')}</Link>
|
|
77
|
-
</Button>
|
|
78
|
-
</div>
|
|
79
|
-
)
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
return (
|
|
83
|
-
<div className="mx-auto flex max-w-sm flex-col gap-4 py-12">
|
|
84
|
-
<Alert status="error">
|
|
85
|
-
<AlertDescription>{error || t('portal.verify.error.generic', 'Email verification failed. Please try again.')}</AlertDescription>
|
|
86
|
-
</Alert>
|
|
87
|
-
<Button asChild variant="outline" className="rounded-lg">
|
|
88
|
-
<Link href={`/${params.orgSlug}/portal/login`}>{t('portal.verify.error.backToLogin', 'Back to sign in')}</Link>
|
|
89
|
-
</Button>
|
|
90
|
-
</div>
|
|
91
|
-
)
|
|
4
|
+
export default function PortalVerifyPage({ params }: { params: { orgSlug: string } }) {
|
|
5
|
+
return <PortalPasswordForm params={params} verify />
|
|
92
6
|
}
|
|
@@ -144,8 +144,9 @@
|
|
|
144
144
|
"portal.verify.error.backToLogin": "Zurück zur Anmeldung",
|
|
145
145
|
"portal.verify.error.generic": "Die E-Mail-Bestätigung ist fehlgeschlagen. Bitte versuchen Sie es erneut.",
|
|
146
146
|
"portal.verify.error.invalidToken": "Das Bestätigungs-Token fehlt.",
|
|
147
|
+
"portal.verify.submit": "E-Mail-Adresse bestätigen und Passwort festlegen",
|
|
147
148
|
"portal.verify.success.description": "Ihre E-Mail-Adresse wurde bestätigt. Sie können sich jetzt im Portal anmelden.",
|
|
148
149
|
"portal.verify.success.loginLink": "Anmelden",
|
|
149
150
|
"portal.verify.success.title": "E-Mail bestätigt",
|
|
150
|
-
"portal.verify.title": "E-Mail
|
|
151
|
+
"portal.verify.title": "E-Mail-Adresse bestätigen"
|
|
151
152
|
}
|
|
@@ -144,8 +144,9 @@
|
|
|
144
144
|
"portal.verify.error.backToLogin": "Back to sign in",
|
|
145
145
|
"portal.verify.error.generic": "Email verification failed. Please try again.",
|
|
146
146
|
"portal.verify.error.invalidToken": "Verification token is missing.",
|
|
147
|
+
"portal.verify.submit": "Verify email and set password",
|
|
147
148
|
"portal.verify.success.description": "Your email has been verified. You can now sign in to the portal.",
|
|
148
149
|
"portal.verify.success.loginLink": "Sign In",
|
|
149
150
|
"portal.verify.success.title": "Email verified",
|
|
150
|
-
"portal.verify.title": "
|
|
151
|
+
"portal.verify.title": "Verify email"
|
|
151
152
|
}
|
|
@@ -144,8 +144,9 @@
|
|
|
144
144
|
"portal.verify.error.backToLogin": "Volver a iniciar sesión",
|
|
145
145
|
"portal.verify.error.generic": "La verificación del correo electrónico falló. Inténtalo de nuevo.",
|
|
146
146
|
"portal.verify.error.invalidToken": "Falta el token de verificación.",
|
|
147
|
+
"portal.verify.submit": "Verificar correo electrónico y establecer contraseña",
|
|
147
148
|
"portal.verify.success.description": "Su correo electrónico ha sido verificado. Ahora puede iniciar sesión en el portal.",
|
|
148
149
|
"portal.verify.success.loginLink": "Iniciar sesión",
|
|
149
150
|
"portal.verify.success.title": "Correo verificado",
|
|
150
|
-
"portal.verify.title": "
|
|
151
|
+
"portal.verify.title": "Verificar correo electrónico"
|
|
151
152
|
}
|
|
@@ -144,8 +144,9 @@
|
|
|
144
144
|
"portal.verify.error.backToLogin": "로그인으로 돌아가기",
|
|
145
145
|
"portal.verify.error.generic": "이메일 인증에 실패했습니다. 다시 시도해 주세요.",
|
|
146
146
|
"portal.verify.error.invalidToken": "인증 토큰이 없습니다.",
|
|
147
|
+
"portal.verify.submit": "이메일 인증 및 비밀번호 설정",
|
|
147
148
|
"portal.verify.success.description": "이메일 인증이 완료되었습니다. 이제 포털에 로그인할 수 있습니다.",
|
|
148
149
|
"portal.verify.success.loginLink": "로그인",
|
|
149
150
|
"portal.verify.success.title": "이메일 인증 완료",
|
|
150
|
-
"portal.verify.title": "이메일 인증
|
|
151
|
+
"portal.verify.title": "이메일 인증"
|
|
151
152
|
}
|
|
@@ -144,8 +144,9 @@
|
|
|
144
144
|
"portal.verify.error.backToLogin": "Wróć do logowania",
|
|
145
145
|
"portal.verify.error.generic": "Weryfikacja adresu e-mail nie powiodła się. Spróbuj ponownie.",
|
|
146
146
|
"portal.verify.error.invalidToken": "Brakuje tokenu weryfikacyjnego.",
|
|
147
|
+
"portal.verify.submit": "Zweryfikuj adres e-mail i ustaw hasło",
|
|
147
148
|
"portal.verify.success.description": "Twój adres e-mail został zweryfikowany. Możesz teraz zalogować się do portalu.",
|
|
148
149
|
"portal.verify.success.loginLink": "Zaloguj się",
|
|
149
150
|
"portal.verify.success.title": "Adres e-mail zweryfikowany",
|
|
150
|
-
"portal.verify.title": "
|
|
151
|
+
"portal.verify.title": "Zweryfikuj adres e-mail"
|
|
151
152
|
}
|