서버 자동로그인 해제
This commit is contained in:
@@ -4,9 +4,10 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { loginUser, type LoginResponse } from '../utils/backendApi';
|
||||
import AppPopup from './AppPopup';
|
||||
|
||||
const DEFAULT_USERNAME = 'admin';
|
||||
const DEFAULT_PASSWORD = 'admin';
|
||||
import {
|
||||
getLoginDefaultPassword,
|
||||
getLoginDefaultUsername,
|
||||
} from '../utils/loginDefaults';
|
||||
|
||||
interface Props {
|
||||
open: boolean;
|
||||
@@ -15,15 +16,15 @@ interface Props {
|
||||
}
|
||||
|
||||
const LoginModal: React.FC<Props> = ({ open, onClose, onSuccess }) => {
|
||||
const [username, setUsername] = useState(DEFAULT_USERNAME);
|
||||
const [password, setPassword] = useState(DEFAULT_PASSWORD);
|
||||
const [username, setUsername] = useState(() => getLoginDefaultUsername());
|
||||
const [password, setPassword] = useState(() => getLoginDefaultPassword());
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (!open) return;
|
||||
setUsername(DEFAULT_USERNAME);
|
||||
setPassword(DEFAULT_PASSWORD);
|
||||
setUsername(getLoginDefaultUsername());
|
||||
setPassword(getLoginDefaultPassword());
|
||||
setError(null);
|
||||
setLoading(false);
|
||||
}, [open]);
|
||||
|
||||
@@ -3,11 +3,13 @@
|
||||
*/
|
||||
import React, { useState } from 'react';
|
||||
import { loginUser, type LoginResponse } from '../utils/backendApi';
|
||||
import {
|
||||
getLoginDefaultPassword,
|
||||
getLoginDefaultUsername,
|
||||
} from '../utils/loginDefaults';
|
||||
import SplashConceptBackdrop from './splash/SplashConceptBackdrop';
|
||||
import '../styles/splashScreen.css';
|
||||
|
||||
const DEFAULT_USERNAME = 'admin';
|
||||
const DEFAULT_PASSWORD = 'admin';
|
||||
const APP_VERSION = '1.0.3';
|
||||
|
||||
interface Props {
|
||||
@@ -16,8 +18,8 @@ interface Props {
|
||||
}
|
||||
|
||||
const SplashScreen: React.FC<Props> = ({ onLoginSuccess, onGuest }) => {
|
||||
const [username, setUsername] = useState(DEFAULT_USERNAME);
|
||||
const [password, setPassword] = useState(DEFAULT_PASSWORD);
|
||||
const [username, setUsername] = useState(() => getLoginDefaultUsername());
|
||||
const [password, setPassword] = useState(() => getLoginDefaultPassword());
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
import { isDesktop } from './platform';
|
||||
|
||||
export const DEV_LOGIN_USERNAME = 'admin';
|
||||
export const DEV_LOGIN_PASSWORD = 'admin123!!';
|
||||
|
||||
/** 로컬 dev·localhost·Desktop — 로그인 폼 admin / admin123!! 자동 입력 */
|
||||
export function shouldPrefillLoginCredentials(): boolean {
|
||||
if (isDesktop()) return true;
|
||||
if (import.meta.env.DEV) return true;
|
||||
if (typeof window !== 'undefined') {
|
||||
const host = window.location.hostname;
|
||||
if (host === 'localhost' || host === '127.0.0.1') return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export function getLoginDefaultUsername(): string {
|
||||
return shouldPrefillLoginCredentials() ? DEV_LOGIN_USERNAME : '';
|
||||
}
|
||||
|
||||
export function getLoginDefaultPassword(): string {
|
||||
return shouldPrefillLoginCredentials() ? DEV_LOGIN_PASSWORD : '';
|
||||
}
|
||||
Reference in New Issue
Block a user