Skip to content

Commit 5c84958

Browse files
authored
Merge pull request #1181 from transformerlab/fix/autologin-singleuser
Fix login page popping up in single user mode
2 parents a1fe7a6 + ef4c784 commit 5c84958

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

src/renderer/components/Login/LoginForm.tsx

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { FaGithub } from 'react-icons/fa6';
1313
import { useNavigate } from 'react-router-dom';
1414
import { useAuth } from '../../lib/authContext';
1515
import { useNotification } from '../Shared/NotificationSystem';
16+
import { API_URL } from '../../lib/api-client/urls';
1617

1718
export default function LoginForm() {
1819
const [email, setEmail] = useState('');
@@ -28,6 +29,38 @@ export default function LoginForm() {
2829
const { addNotification } = useNotification();
2930
const navigate = useNavigate();
3031

32+
// Auto-login for single user mode
33+
useEffect(() => {
34+
const autoLogin = async () => {
35+
// Only attempt auto-login if we have a valid API URL (connection is established)
36+
const apiUrl = API_URL();
37+
if (!apiUrl) {
38+
console.log('Skipping auto-login: no API URL available.');
39+
return;
40+
}
41+
42+
// Only auto-login if MULTIUSER is not enabled
43+
// Check window.platform first (cloud mode), then fallback to process.env
44+
const isMultiUserMode =
45+
(window as any).platform?.multiuser === true ||
46+
(typeof process !== 'undefined' &&
47+
process.env &&
48+
process.env.MULTIUSER === 'true');
49+
if (isMultiUserMode) {
50+
return;
51+
}
52+
53+
try {
54+
console.log('Attempting auto-login for single user mode');
55+
await login('admin@example.com', 'admin123');
56+
} catch (error) {
57+
console.error('Auto-login failed:', error);
58+
}
59+
};
60+
61+
autoLogin();
62+
}, [login]);
63+
3164
// Check OAuth status on component mount
3265
useEffect(() => {
3366
const checkOAuthStatus = async () => {

0 commit comments

Comments
 (0)