feat(auth): add dedicated successfully logged out page with url login support (issue #83)

- Add LoggedOutView component displaying 'Successfully Logged Out' message and security notice
- Provide 'Log In Again' action with direct URL (?login=true) and 'Browse Storefront' button
- Support /store/logged-out routing and query parameter so page reloads without base URL errors
- Switch to logged-out tab on session logout and redirect back to storefront upon re-authentication
This commit is contained in:
ShivaniKhaire 2026-11-17 12:20:33 +05:30
parent 401ebb40d5
commit 9f547d587e
3 changed files with 130 additions and 8 deletions

View File

@ -20,20 +20,27 @@ import { ProfileDrawer } from './components/auth/ProfileDrawer';
import { PaymentSuccessModal } from './components/checkout/PaymentSuccessModal';
import { PasswordUpdatedModal } from './components/auth/PasswordUpdatedModal';
import { BillingPhoneModal } from './components/checkout/BillingPhoneModal';
import { LoggedOutView } from './components/auth/LoggedOutView';
import { openMobileApp, DEFAULT_RETURN_ROUTE } from './utils/navigation';
const getInitialTab = (): 'storefront' | 'subscriptions' => {
const getInitialTab = (): 'storefront' | 'subscriptions' | 'logged-out' => {
if (typeof window !== 'undefined') {
const path = window.location.pathname.toLowerCase();
if (path.includes('/logged-out')) return 'logged-out';
if (path.includes('/subscriptions')) return 'subscriptions';
const params = new URLSearchParams(window.location.search);
if (params.get('logged_out') === 'true' || params.get('status') === 'logged-out') {
return 'logged-out';
}
}
return 'storefront';
};
export default function App() {
const [activeTab, setActiveTab] = useState<'storefront' | 'subscriptions'>(getInitialTab);
const [activeTab, setActiveTab] = useState<'storefront' | 'subscriptions' | 'logged-out'>(getInitialTab);
const switchTab = (tab: 'storefront' | 'subscriptions') => {
const switchTab = (tab: 'storefront' | 'subscriptions' | 'logged-out') => {
setActiveTab(tab);
if (typeof window !== 'undefined') {
const isStorePrefix = window.location.pathname.startsWith('/store');
@ -251,6 +258,12 @@ export default function App() {
const urlPlanCode = params.get('planCode');
const urlReturnRoute = params.get('returnRoute') || params.get('redirectPath') || params.get('redirect');
const urlScheme = params.get('scheme');
const shouldOpenLogin = params.get('login') === 'true' || params.get('auth') === 'login';
if (shouldOpenLogin) {
setAuthMode('login');
setShowAuthModal(true);
}
if (urlReturnRoute) {
setReturnRoute(urlReturnRoute);
@ -282,10 +295,15 @@ export default function App() {
}
}
if (urlToken || urlPlanCode) {
if (urlToken || urlPlanCode || shouldOpenLogin) {
const isStorePrefix = window.location.pathname.startsWith('/store');
const basePath = isStorePrefix ? '/store/' : '/';
const cleanPath = activeTab === 'subscriptions' ? `${basePath}subscriptions` : basePath;
const cleanPath =
activeTab === 'subscriptions'
? `${basePath}subscriptions`
: activeTab === 'logged-out'
? `${basePath}logged-out`
: basePath;
window.history.replaceState({}, document.title, cleanPath);
}
@ -354,13 +372,14 @@ export default function App() {
setAppliedCoupon(null);
setCouponCode('');
setPricingCalc(null);
switchTab('storefront');
setShowProfileDrawer(false);
setProfileDisplayName('');
setProfilePhone('');
setProfileCountry('India');
setProfileError(null);
setProfileSuccess(false);
setShowAuthModal(false);
switchTab('logged-out');
};
const handleUpdateProfile = async (e: React.FormEvent) => {
@ -510,6 +529,9 @@ export default function App() {
setAuthEmail('');
setAuthDisplayName('');
setAuthPhone('');
if (activeTab === 'logged-out') {
switchTab('storefront');
}
} catch (err: any) {
setAuthError(err.response?.data?.detail || 'Authentication failed. Please check credentials.');
} finally {
@ -1064,6 +1086,15 @@ export default function App() {
/>
</div>
</div>
) : activeTab === 'logged-out' ? (
<LoggedOutView
onLoginAgain={() => {
switchTab('storefront');
setAuthMode('login');
setShowAuthModal(true);
}}
onBrowseStore={() => switchTab('storefront')}
/>
) : (
/* 🧾 Tab: User Personal Subscriptions Ledger */
<SubscriptionsView

View File

@ -0,0 +1,91 @@
import React from 'react';
import { LogOut, LogIn, ShoppingBag, ShieldCheck } from 'lucide-react';
interface LoggedOutViewProps {
onLoginAgain: () => void;
onBrowseStore: () => void;
}
export const LoggedOutView: React.FC<LoggedOutViewProps> = ({
onLoginAgain,
onBrowseStore,
}) => {
const isStorePrefix =
typeof window !== 'undefined' && window.location.pathname.startsWith('/store');
const basePath = isStorePrefix ? '/store/' : '/';
const loginUrl = `${basePath}?login=true`;
const loginDisplayUrl =
typeof window !== 'undefined'
? `${window.location.origin}${loginUrl}`
: loginUrl;
return (
<div className="flex-1 flex items-center justify-center py-10 px-4">
<div className="max-w-md w-full bg-white rounded-3xl border border-slate-200/80 shadow-xl shadow-slate-200/50 p-6 sm:p-8 text-center">
{/* Status Badge Icon */}
<div className="w-16 h-16 rounded-2xl bg-indigo-50 border border-indigo-100 flex items-center justify-center mx-auto mb-5 text-indigo-600 shadow-sm">
<LogOut className="w-8 h-8" />
</div>
{/* Title & Description */}
<h2 className="text-2xl font-black text-slate-900 tracking-tight mb-2">
Successfully Logged Out
</h2>
<p className="text-sm text-slate-500 mb-6 leading-relaxed">
You have been securely signed out of your AcuPedia session. Thank you for using our platform.
</p>
{/* Security Notice */}
<div className="bg-slate-50 border border-slate-100 rounded-2xl p-3.5 mb-6 text-left flex items-start gap-3">
<ShieldCheck className="w-4 h-4 text-emerald-600 flex-shrink-0 mt-0.5" />
<p className="text-xs text-slate-500 leading-normal">
For security, please close your browser window if you are using a shared or public device.
</p>
</div>
{/* Actions */}
<div className="space-y-3">
{/* Primary: Log In Again via URL / Button */}
<a
href={loginUrl}
onClick={(e) => {
e.preventDefault();
onLoginAgain();
}}
className="w-full inline-flex items-center justify-center gap-2 px-5 py-3 rounded-xl text-xs sm:text-sm font-bold text-white bg-indigo-600 hover:bg-indigo-500 shadow-md shadow-indigo-600/20 transition-all hover:scale-[1.01] active:scale-[0.99] cursor-pointer"
>
<LogIn className="w-4 h-4" />
Log In Again
</a>
{/* Secondary: Browse Storefront */}
<button
type="button"
onClick={onBrowseStore}
className="w-full inline-flex items-center justify-center gap-2 px-5 py-3 rounded-xl text-xs sm:text-sm font-semibold text-slate-600 hover:text-slate-900 bg-slate-100 hover:bg-slate-200 transition-colors cursor-pointer"
>
<ShoppingBag className="w-4 h-4" />
Browse Storefront
</button>
</div>
{/* Option to login in again via URL (explicit link for user / copy) */}
<div className="pt-6 border-t border-slate-100 mt-6 text-xs text-slate-400">
Want to sign in directly via URL?
<div className="mt-1">
<a
href={loginUrl}
onClick={(e) => {
e.preventDefault();
onLoginAgain();
}}
className="text-indigo-600 hover:text-indigo-700 font-semibold underline underline-offset-2 break-all"
>
{loginDisplayUrl}
</a>
</div>
</div>
</div>
</div>
);
};

View File

@ -3,8 +3,8 @@ import { Sparkles, LogIn, UserPlus, BookOpen, CheckCircle } from 'lucide-react';
import type { UserProfile } from '../../types';
interface StoreHeaderProps {
activeTab: 'storefront' | 'subscriptions';
onSwitchTab: (tab: 'storefront' | 'subscriptions') => void;
activeTab: 'storefront' | 'subscriptions' | 'logged-out';
onSwitchTab: (tab: 'storefront' | 'subscriptions' | 'logged-out') => void;
loggedInUser: UserProfile | null;
onOpenProfile: () => void;
onOpenAuth: (mode: 'login' | 'register') => void;