sso-login调整
This commit is contained in:
+4
-27
@@ -1,6 +1,6 @@
|
||||
import { useState, useEffect } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { User, Lock, Building2, LogIn, AlertCircle, Loader2 } from 'lucide-react';
|
||||
import { User, Lock, LogIn, AlertCircle, Loader2 } from 'lucide-react';
|
||||
import StarBackground from '@/shared/components/StarBackground';
|
||||
import { iamLogin, saveSession } from '@/shared/services/iamAuth';
|
||||
import { useTheme } from '@/shared/context/ThemeContext';
|
||||
@@ -33,7 +33,6 @@ export default function LoginPage() {
|
||||
|
||||
const [userId, setUserId] = useState('');
|
||||
const [password, setPassword] = useState('');
|
||||
const [tenantId, setTenantId] = useState('');
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [error, setError] = useState('');
|
||||
|
||||
@@ -51,12 +50,8 @@ export default function LoginPage() {
|
||||
setLoading(true);
|
||||
setError('');
|
||||
try {
|
||||
const result = await iamLogin({ userId: userId.trim(), password, tenantId: tenantId.trim() || undefined });
|
||||
saveSession(result.token, {
|
||||
userId: result.userId,
|
||||
tenantId: result.tenantId,
|
||||
loginTime: new Date().toLocaleString('zh-CN'),
|
||||
});
|
||||
const result = await iamLogin({ userId: userId.trim(), password });
|
||||
saveSession(result.token, result.userInfo);
|
||||
navigate('/', { replace: true });
|
||||
} catch (ex) {
|
||||
setError(ex instanceof Error ? ex.message : '登录失败,请稍后重试');
|
||||
@@ -138,7 +133,7 @@ export default function LoginPage() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style={{ marginBottom: 16 }}>
|
||||
<div style={{ marginBottom: 20 }}>
|
||||
<label style={{ display: 'block', fontSize: 13, marginBottom: 6, color: isDark ? 'rgba(168,216,255,0.8)' : '#475569' }}>
|
||||
密码
|
||||
</label>
|
||||
@@ -157,24 +152,6 @@ export default function LoginPage() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style={{ marginBottom: 20 }}>
|
||||
<label style={{ display: 'block', fontSize: 13, marginBottom: 6, color: isDark ? 'rgba(168,216,255,0.8)' : '#475569' }}>
|
||||
租户 ID(可选)
|
||||
</label>
|
||||
<div style={{ position: 'relative' }}>
|
||||
<Building2 size={16} style={iconStyle(isDark)} />
|
||||
<input
|
||||
type="text"
|
||||
value={tenantId}
|
||||
onChange={(e) => setTenantId(e.target.value)}
|
||||
placeholder="不填则自动匹配已授权租户"
|
||||
style={inputStyle(isDark)}
|
||||
onFocus={(e) => { e.currentTarget.style.borderColor = '#00d4ff'; }}
|
||||
onBlur={(e) => { e.currentTarget.style.borderColor = isDark ? 'rgba(0,212,255,0.25)' : 'rgba(0,0,0,0.12)'; }}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{error && (
|
||||
<div style={{
|
||||
display: 'flex', alignItems: 'center', gap: 8,
|
||||
|
||||
Reference in New Issue
Block a user