Add environment variable to control local login availability

Add VITE_ENABLE_LOCAL_LOGIN env variable to conditionally show/hide
local username/password login on the login screen. When set to 'false'
(production), only Microsoft login is shown. When 'true' (development),
both options are available.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
michael 2025-12-08 14:20:50 -06:00
parent 8a9c7c3cb6
commit 6b7f8763c0
3 changed files with 77 additions and 62 deletions

View file

@ -11,3 +11,6 @@ VITE_WEBSOCKET_PATH=/socket.io/
# MSAL Authentication (local development)
VITE_MSAL_REDIRECT_URI=http://localhost:5173/
VITE_MSAL_POST_LOGOUT_REDIRECT_URI=http://localhost:5173/
# Local login (username/password) - enable for development
VITE_ENABLE_LOCAL_LOGIN=true

View file

@ -11,3 +11,6 @@ VITE_WEBSOCKET_PATH=/semblance_back/socket.io/
# MSAL Authentication (production server)
VITE_MSAL_REDIRECT_URI=https://ai-sandbox.oliver.solutions/semblance
VITE_MSAL_POST_LOGOUT_REDIRECT_URI=https://ai-sandbox.oliver.solutions/semblance
# Local login (username/password) - disable for production
VITE_ENABLE_LOCAL_LOGIN=false

View file

@ -25,6 +25,9 @@ export default function Login() {
const { login, loginWithMicrosoft, isAuthenticated, isMsalLoading } = useAuth();
const [isLoading, setIsLoading] = useState(false);
// Check if local login is enabled (defaults to true for backwards compatibility)
const enableLocalLogin = import.meta.env.VITE_ENABLE_LOCAL_LOGIN !== 'false';
// Get the intended destination from state, or default to home page
const from = location.state?.from || '/';
@ -120,6 +123,8 @@ export default function Login() {
</Button>
</div>
{enableLocalLogin && (
<>
{/* Divider */}
<div className="relative mb-6">
<div className="absolute inset-0 flex items-center">
@ -178,12 +183,16 @@ export default function Login() {
</Button>
</form>
</Form>
</>
)}
</CardContent>
<CardFooter className="flex flex-col space-y-2">
{enableLocalLogin && (
<div className="text-sm text-center text-gray-500 mb-2">
Default account: user / pass
</div>
)}
{!isLoading && !isMsalLoading && (
<div className="flex flex-col items-center justify-center gap-2">
<Button