서버 자동로그인 해제
This commit is contained in:
@@ -4,9 +4,10 @@
|
|||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import { loginUser, type LoginResponse } from '../utils/backendApi';
|
import { loginUser, type LoginResponse } from '../utils/backendApi';
|
||||||
import AppPopup from './AppPopup';
|
import AppPopup from './AppPopup';
|
||||||
|
import {
|
||||||
const DEFAULT_USERNAME = 'admin';
|
getLoginDefaultPassword,
|
||||||
const DEFAULT_PASSWORD = 'admin';
|
getLoginDefaultUsername,
|
||||||
|
} from '../utils/loginDefaults';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
open: boolean;
|
open: boolean;
|
||||||
@@ -15,15 +16,15 @@ interface Props {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const LoginModal: React.FC<Props> = ({ open, onClose, onSuccess }) => {
|
const LoginModal: React.FC<Props> = ({ open, onClose, onSuccess }) => {
|
||||||
const [username, setUsername] = useState(DEFAULT_USERNAME);
|
const [username, setUsername] = useState(() => getLoginDefaultUsername());
|
||||||
const [password, setPassword] = useState(DEFAULT_PASSWORD);
|
const [password, setPassword] = useState(() => getLoginDefaultPassword());
|
||||||
const [error, setError] = useState<string | null>(null);
|
const [error, setError] = useState<string | null>(null);
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!open) return;
|
if (!open) return;
|
||||||
setUsername(DEFAULT_USERNAME);
|
setUsername(getLoginDefaultUsername());
|
||||||
setPassword(DEFAULT_PASSWORD);
|
setPassword(getLoginDefaultPassword());
|
||||||
setError(null);
|
setError(null);
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}, [open]);
|
}, [open]);
|
||||||
|
|||||||
@@ -3,11 +3,13 @@
|
|||||||
*/
|
*/
|
||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import { loginUser, type LoginResponse } from '../utils/backendApi';
|
import { loginUser, type LoginResponse } from '../utils/backendApi';
|
||||||
|
import {
|
||||||
|
getLoginDefaultPassword,
|
||||||
|
getLoginDefaultUsername,
|
||||||
|
} from '../utils/loginDefaults';
|
||||||
import SplashConceptBackdrop from './splash/SplashConceptBackdrop';
|
import SplashConceptBackdrop from './splash/SplashConceptBackdrop';
|
||||||
import '../styles/splashScreen.css';
|
import '../styles/splashScreen.css';
|
||||||
|
|
||||||
const DEFAULT_USERNAME = 'admin';
|
|
||||||
const DEFAULT_PASSWORD = 'admin';
|
|
||||||
const APP_VERSION = '1.0.3';
|
const APP_VERSION = '1.0.3';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@@ -16,8 +18,8 @@ interface Props {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const SplashScreen: React.FC<Props> = ({ onLoginSuccess, onGuest }) => {
|
const SplashScreen: React.FC<Props> = ({ onLoginSuccess, onGuest }) => {
|
||||||
const [username, setUsername] = useState(DEFAULT_USERNAME);
|
const [username, setUsername] = useState(() => getLoginDefaultUsername());
|
||||||
const [password, setPassword] = useState(DEFAULT_PASSWORD);
|
const [password, setPassword] = useState(() => getLoginDefaultPassword());
|
||||||
const [error, setError] = useState<string | null>(null);
|
const [error, setError] = useState<string | null>(null);
|
||||||
const [loading, setLoading] = useState(false);
|
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