fix(auth-issue-68): update registration copy to Create Account, block same password, and require re-authentication
This commit is contained in:
parent
8dc9d871d9
commit
687fad2ff0
27
src/App.tsx
27
src/App.tsx
|
|
@ -488,6 +488,10 @@ export default function App() {
|
||||||
setChangePasswordError(pwdError);
|
setChangePasswordError(pwdError);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (changeOldPassword === changeNewPassword) {
|
||||||
|
setChangePasswordError('New password cannot be the same as current password.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (changeNewPassword !== changeConfirmPassword) {
|
if (changeNewPassword !== changeConfirmPassword) {
|
||||||
setChangePasswordError('New passwords do not match.');
|
setChangePasswordError('New passwords do not match.');
|
||||||
return;
|
return;
|
||||||
|
|
@ -501,12 +505,25 @@ export default function App() {
|
||||||
}, {
|
}, {
|
||||||
headers: { 'Authorization': `Bearer ${userToken}` }
|
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('');
|
setChangeOldPassword('');
|
||||||
setChangeNewPassword('');
|
setChangeNewPassword('');
|
||||||
setChangeConfirmPassword('');
|
setChangeConfirmPassword('');
|
||||||
setShowPasswordChange(false);
|
setShowPasswordChange(false);
|
||||||
|
setChangePasswordSuccess(true);
|
||||||
|
setPasswordUpdatedPopup(true);
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
setChangePasswordError(err.response?.data?.detail || 'Failed to update password.');
|
setChangePasswordError(err.response?.data?.detail || 'Failed to update password.');
|
||||||
|
|
@ -1148,7 +1165,11 @@ export default function App() {
|
||||||
{/* 🔐 Password Updated Success Modal */}
|
{/* 🔐 Password Updated Success Modal */}
|
||||||
<PasswordUpdatedModal
|
<PasswordUpdatedModal
|
||||||
isOpen={passwordUpdatedPopup}
|
isOpen={passwordUpdatedPopup}
|
||||||
onClose={() => setPasswordUpdatedPopup(false)}
|
onClose={() => {
|
||||||
|
setPasswordUpdatedPopup(false);
|
||||||
|
setAuthMode('login');
|
||||||
|
setShowAuthModal(true);
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -101,14 +101,14 @@ export const AuthModal: React.FC<AuthModalProps> = ({
|
||||||
{authMode === 'login'
|
{authMode === 'login'
|
||||||
? 'Welcome Back!'
|
? 'Welcome Back!'
|
||||||
: authMode === 'register'
|
: authMode === 'register'
|
||||||
? 'Create Clinical Account'
|
? 'Create Account'
|
||||||
: 'Reset Password'}
|
: 'Reset Password'}
|
||||||
</h3>
|
</h3>
|
||||||
<p className="text-xs text-slate-400 leading-relaxed font-semibold">
|
<p className="text-xs text-slate-400 leading-relaxed font-semibold">
|
||||||
{authMode === 'login'
|
{authMode === 'login'
|
||||||
? 'Sign in to access your saved TCM modules and invoices.'
|
? 'Sign in to access your saved TCM modules and invoices.'
|
||||||
: authMode === 'register'
|
: authMode === 'register'
|
||||||
? 'Onboard as a clinical practitioner to access TCM modules.'
|
? 'Sign up to get started and access TCM modules.'
|
||||||
: resetStep === 'request'
|
: resetStep === 'request'
|
||||||
? 'Enter your registered email to receive a 6-digit verification code.'
|
? 'Enter your registered email to receive a 6-digit verification code.'
|
||||||
: 'Enter the 6-digit code sent to your email and your new password.'}
|
: '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' ? <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>
|
</button>
|
||||||
|
|
@ -430,7 +430,7 @@ export const AuthModal: React.FC<AuthModalProps> = ({
|
||||||
}}
|
}}
|
||||||
className="text-indigo-400 hover:text-indigo-300 font-bold underline"
|
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>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,18 @@ import { CheckCircle } from 'lucide-react';
|
||||||
interface PasswordUpdatedModalProps {
|
interface PasswordUpdatedModalProps {
|
||||||
isOpen: boolean;
|
isOpen: boolean;
|
||||||
onClose: () => void;
|
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;
|
if (!isOpen) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
@ -16,16 +25,16 @@ export const PasswordUpdatedModal: React.FC<PasswordUpdatedModalProps> = ({ isOp
|
||||||
<CheckCircle className="h-8 w-8" />
|
<CheckCircle className="h-8 w-8" />
|
||||||
</div>
|
</div>
|
||||||
<div className="space-y-1.5">
|
<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">
|
<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>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<button
|
<button
|
||||||
onClick={onClose}
|
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>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue