diff --git a/src/App.tsx b/src/App.tsx index a5c5d6b..bb06cb6 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -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 */} setPasswordUpdatedPopup(false)} + onClose={() => { + setPasswordUpdatedPopup(false); + setAuthMode('login'); + setShowAuthModal(true); + }} /> ); diff --git a/src/components/auth/AuthModal.tsx b/src/components/auth/AuthModal.tsx index 137fe37..d0664fc 100644 --- a/src/components/auth/AuthModal.tsx +++ b/src/components/auth/AuthModal.tsx @@ -101,14 +101,14 @@ export const AuthModal: React.FC = ({ {authMode === 'login' ? 'Welcome Back!' : authMode === 'register' - ? 'Create Clinical Account' + ? 'Create Account' : 'Reset Password'}

{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 = ({ ) : ( <> {authMode === 'login' ? : } - {authMode === 'login' ? 'Sign In Session' : 'Register Clinical Profile'} + {authMode === 'login' ? 'Sign In' : 'Create Account'} )} @@ -430,7 +430,7 @@ export const AuthModal: React.FC = ({ }} 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'} )} diff --git a/src/components/auth/PasswordUpdatedModal.tsx b/src/components/auth/PasswordUpdatedModal.tsx index cff0311..bb8c780 100644 --- a/src/components/auth/PasswordUpdatedModal.tsx +++ b/src/components/auth/PasswordUpdatedModal.tsx @@ -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 = ({ isOpen, onClose }) => { +export const PasswordUpdatedModal: React.FC = ({ + 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 = ({ isOp

-

Password Updated!

+

{title}

- Your password has been securely updated. You can now use your new password across the storefront and mobile application. + {description}