diff --git a/frontend/src/components/SimpleLogin.tsx b/frontend/src/components/SimpleLogin.tsx index 8a4f2d6..14d6959 100644 --- a/frontend/src/components/SimpleLogin.tsx +++ b/frontend/src/components/SimpleLogin.tsx @@ -1,24 +1,48 @@ /** - * Simple Login Component (for test users only) + * Login Component * - * This component is for testing purposes only. - * In production, only MSAL authentication will be used. + * Shows Azure AD SSO login when configured, otherwise falls back to simple login for testing. */ import React, { useState } from 'react'; import { authAPI } from '../services/api'; +import { useAuth } from '../context/AuthContext'; + +// Check if Azure AD is configured +const isAzureConfigured = + process.env.REACT_APP_AZURE_CLIENT_ID && + process.env.REACT_APP_AZURE_CLIENT_ID !== 'your-client-id-here' && + process.env.REACT_APP_AZURE_TENANT_ID && + process.env.REACT_APP_AZURE_TENANT_ID !== 'your-tenant-id-here'; interface SimpleLoginProps { onLoginSuccess: (token: string, user: any) => void; } const SimpleLogin: React.FC = ({ onLoginSuccess }) => { + const { login: msalLogin, isLoading: msalLoading } = useAuth(); const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const [isLoading, setIsLoading] = useState(false); const [error, setError] = useState(null); - const handleSubmit = async (e: React.FormEvent) => { + // Azure AD Login + const handleAzureLogin = async () => { + setError(null); + try { + await msalLogin(); + } catch (err: any) { + console.error('Azure AD login failed:', err); + if (err.message) { + setError(err.message); + } else { + setError('Login failed. Please try again.'); + } + } + }; + + // Simple login (for testing) + const handleSimpleSubmit = async (e: React.FormEvent) => { e.preventDefault(); setError(null); setIsLoading(true); @@ -64,6 +88,39 @@ const SimpleLogin: React.FC = ({ onLoginSuccess }) => { setPassword('user'); }; + // Azure AD Login UI + if (isAzureConfigured) { + return ( +
+
+
+

🤖 Seapac Ops Bot

+

AI Operations Assistant

+
+ + {error && ( +
+ {error} +
+ )} + + + +

+ Sign in with your Oliver Agency account +

+
+
+ ); + } + + // Simple Login UI (for testing only) return (
@@ -73,7 +130,7 @@ const SimpleLogin: React.FC = ({ onLoginSuccess }) => {

⚠️ For testing only. Production uses Azure AD.

-
+