fix(auth-issue-68): update registration copy to Create Account, block same password, and require re-authentication

This commit is contained in:
Urvish Prajapati 2026-10-29 15:52:04 +05:30
parent 8dc9d871d9
commit 687fad2ff0
3 changed files with 42 additions and 12 deletions

View File

@ -488,6 +488,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;
@ -501,12 +505,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.');
@ -1148,7 +1165,11 @@ export default function App() {
{/* 🔐 Password Updated Success Modal */}
<PasswordUpdatedModal
isOpen={passwordUpdatedPopup}
onClose={() => setPasswordUpdatedPopup(false)}
onClose={() => {
setPasswordUpdatedPopup(false);
setAuthMode('login');
setShowAuthModal(true);
}}
/>
</div>
);

View File

@ -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.'}
@ -409,7 +409,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>
@ -430,7 +430,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>
)}

View File

@ -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>