Merge pull request 'fix(auth-issue-68): update registration copy to Create Account, block same password, and require re-authentication' (#76) from fix/change-password-validation-and-reauth into main
Reviewed-on: https://git.zedobject.local/AcuPedia/acupedia-store-ui/pulls/76 Reviewed-by: Amit Salunke <amit@noreply.localhost>
This commit is contained in:
commit
817be0ab9e
27
src/App.tsx
27
src/App.tsx
|
|
@ -501,6 +501,10 @@ export default function App() {
|
|||
setChangePasswordError(pwdError);
|
||||
return;
|
||||
}
|
||||
if (changeOldPassword === changeNewPassword) {
|
||||
setChangePasswordError('New password cannot be the same as current password.');
|
||||
return;
|
||||
}
|
||||
if (changeNewPassword !== changeConfirmPassword) {
|
||||
setChangePasswordError('New passwords do not match.');
|
||||
return;
|
||||
|
|
@ -514,12 +518,25 @@ export default function App() {
|
|||
}, {
|
||||
headers: { 'Authorization': `Bearer ${userToken}` }
|
||||
});
|
||||
setChangePasswordSuccess(true);
|
||||
setPasswordUpdatedPopup(true);
|
||||
|
||||
const userEmail = loggedInUser?.email || authEmail;
|
||||
|
||||
// Invalidate active session so re-authentication is required
|
||||
handleLogout();
|
||||
setShowProfileDrawer(false);
|
||||
|
||||
// Pre-fill email and set auth mode to login for seamless re-auth
|
||||
setAuthEmail(userEmail);
|
||||
setAuthPassword('');
|
||||
setAuthMode('login');
|
||||
setAuthError(null);
|
||||
|
||||
setChangeOldPassword('');
|
||||
setChangeNewPassword('');
|
||||
setChangeConfirmPassword('');
|
||||
setShowPasswordChange(false);
|
||||
setChangePasswordSuccess(true);
|
||||
setPasswordUpdatedPopup(true);
|
||||
} catch (err: any) {
|
||||
console.error(err);
|
||||
setChangePasswordError(err.response?.data?.detail || 'Failed to update password.');
|
||||
|
|
@ -1180,7 +1197,11 @@ export default function App() {
|
|||
{/* 🔐 Password Updated Success Modal */}
|
||||
<PasswordUpdatedModal
|
||||
isOpen={passwordUpdatedPopup}
|
||||
onClose={() => setPasswordUpdatedPopup(false)}
|
||||
onClose={() => {
|
||||
setPasswordUpdatedPopup(false);
|
||||
setAuthMode('login');
|
||||
setShowAuthModal(true);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -101,14 +101,14 @@ export const AuthModal: React.FC<AuthModalProps> = ({
|
|||
{authMode === 'login'
|
||||
? 'Welcome Back!'
|
||||
: authMode === 'register'
|
||||
? 'Create Clinical Account'
|
||||
? 'Create Account'
|
||||
: 'Reset Password'}
|
||||
</h3>
|
||||
<p className="text-xs text-slate-400 leading-relaxed font-semibold">
|
||||
{authMode === 'login'
|
||||
? 'Sign in to access your saved TCM modules and invoices.'
|
||||
: authMode === 'register'
|
||||
? 'Onboard as a clinical practitioner to access TCM modules.'
|
||||
? 'Sign up to get started and access TCM modules.'
|
||||
: resetStep === 'request'
|
||||
? 'Enter your registered email to receive a 6-digit verification code.'
|
||||
: 'Enter the 6-digit code sent to your email and your new password.'}
|
||||
|
|
@ -411,7 +411,7 @@ export const AuthModal: React.FC<AuthModalProps> = ({
|
|||
) : (
|
||||
<>
|
||||
{authMode === 'login' ? <LogIn className="h-4 w-4" /> : <UserPlus className="h-4 w-4" />}
|
||||
{authMode === 'login' ? 'Sign In Session' : 'Register Clinical Profile'}
|
||||
{authMode === 'login' ? 'Sign In' : 'Create Account'}
|
||||
</>
|
||||
)}
|
||||
</button>
|
||||
|
|
@ -432,7 +432,7 @@ export const AuthModal: React.FC<AuthModalProps> = ({
|
|||
}}
|
||||
className="text-indigo-400 hover:text-indigo-300 font-bold underline"
|
||||
>
|
||||
{authMode === 'login' ? 'Create clinical account' : 'Sign in here'}
|
||||
{authMode === 'login' ? 'Create an account' : 'Sign in here'}
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
|
|
|
|||
|
|
@ -4,9 +4,18 @@ import { CheckCircle } from 'lucide-react';
|
|||
interface PasswordUpdatedModalProps {
|
||||
isOpen: boolean;
|
||||
onClose: () => void;
|
||||
title?: string;
|
||||
description?: string;
|
||||
buttonText?: string;
|
||||
}
|
||||
|
||||
export const PasswordUpdatedModal: React.FC<PasswordUpdatedModalProps> = ({ isOpen, onClose }) => {
|
||||
export const PasswordUpdatedModal: React.FC<PasswordUpdatedModalProps> = ({
|
||||
isOpen,
|
||||
onClose,
|
||||
title = 'Password Updated!',
|
||||
description = 'Your password has been securely updated. Please log in again with your new password to continue.',
|
||||
buttonText = 'Log In with New Password'
|
||||
}) => {
|
||||
if (!isOpen) return null;
|
||||
|
||||
return (
|
||||
|
|
@ -16,16 +25,16 @@ export const PasswordUpdatedModal: React.FC<PasswordUpdatedModalProps> = ({ isOp
|
|||
<CheckCircle className="h-8 w-8" />
|
||||
</div>
|
||||
<div className="space-y-1.5">
|
||||
<h3 className="text-lg font-bold text-white">Password Updated!</h3>
|
||||
<h3 className="text-lg font-bold text-white">{title}</h3>
|
||||
<p className="text-xs text-slate-400 leading-relaxed font-medium">
|
||||
Your password has been securely updated. You can now use your new password across the storefront and mobile application.
|
||||
{description}
|
||||
</p>
|
||||
</div>
|
||||
<button
|
||||
onClick={onClose}
|
||||
className="w-full py-2.5 bg-emerald-600 hover:bg-emerald-500 text-white font-bold text-xs rounded-xl transition-colors shadow-lg shadow-emerald-600/20"
|
||||
className="w-full py-2.5 bg-emerald-600 hover:bg-emerald-500 text-white font-bold text-xs rounded-xl transition-colors shadow-lg shadow-emerald-600/20 cursor-pointer"
|
||||
>
|
||||
Continue to Storefront
|
||||
{buttonText}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in New Issue