refactor: remove demo mode — all auth goes through sidecar, call desk is live-only

This commit is contained in:
2026-03-18 08:45:42 +05:30
parent 125aeae41c
commit d846d97377
2 changed files with 42 additions and 272 deletions

View File

@@ -42,31 +42,26 @@ export const LoginPage = () => {
event.preventDefault();
setError(null);
// If email and password are provided, try real auth via sidecar
if (email && password) {
setIsLoading(true);
try {
const { apiClient } = await import('@/lib/api-client');
await apiClient.login(email, password);
login(); // Also set mock auth state for the role-based UI
navigate('/');
} catch (err: any) {
// If sidecar is down, fall back to demo mode
console.warn('Real auth failed, falling back to demo mode:', err.message);
setError(err.message);
setIsLoading(false);
}
if (!email || !password) {
setError('Email and password are required');
return;
}
// No credentials — demo mode (mock auth)
login();
navigate('/');
setIsLoading(true);
try {
const { apiClient } = await import('@/lib/api-client');
await apiClient.login(email, password);
login();
navigate('/');
} catch (err: any) {
setError(err.message);
setIsLoading(false);
}
};
const handleGoogleSignIn = () => {
login();
navigate('/');
// TODO: implement Google OAuth via sidecar
setError('Google sign-in not yet configured');
};
return (
@@ -229,14 +224,9 @@ export const LoginPage = () => {
isLoading={isLoading}
className="w-full rounded-xl py-3 font-semibold active:scale-[0.98] transition duration-300 ease-[cubic-bezier(0.4,0,0.2,1)]"
>
{email ? 'Sign in' : 'Demo Mode'}
Sign in
</Button>
</div>
{!email && (
<p className="mt-2 text-center text-xs text-quaternary">
Leave email empty for demo mode with mock data
</p>
)}
</form>
</div>
</div>