feat: harden platform workflows and UI governance
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { adminApi, clientApi, type CaptchaResponse } from '@/api/adminApi';
|
||||
import { writeSession, type Portal } from '@/api/session';
|
||||
import { consumeSessionRecovery, readSessionRecovery, writeSession, type Portal } from '@/api/session';
|
||||
import { Button, Input, Modal } from '@/components/ui';
|
||||
|
||||
type LoginPageProps = {
|
||||
@@ -31,6 +31,7 @@ export function LoginPage({ portal }: LoginPageProps) {
|
||||
const [alertMessage, setAlertMessage] = useState('');
|
||||
const [loading, setLoading] = useState(false);
|
||||
const isAdmin = portal === 'admin';
|
||||
const recovery = readSessionRecovery(portal);
|
||||
|
||||
async function refreshCaptcha(options: { clearError?: boolean } = {}) {
|
||||
if (options.clearError ?? true) {
|
||||
@@ -56,7 +57,8 @@ export function LoginPage({ portal }: LoginPageProps) {
|
||||
captchaText,
|
||||
});
|
||||
writeSession(session);
|
||||
navigate(isAdmin ? '/admin' : '/client', { replace: true });
|
||||
const target = consumeSessionRecovery(portal)?.returnUrl;
|
||||
navigate(target ?? (isAdmin ? '/admin' : '/client'), { replace: true });
|
||||
} catch (err) {
|
||||
const message = loginErrorMessage(err);
|
||||
setError(message);
|
||||
@@ -78,6 +80,11 @@ export function LoginPage({ portal }: LoginPageProps) {
|
||||
</div>
|
||||
</div>
|
||||
<div className="login-form">
|
||||
{recovery ? (
|
||||
<p className="login-session-notice" role="status">
|
||||
{recovery.message ?? '登录会话已失效,请重新登录。'} 登录成功后将返回之前访问的页面。
|
||||
</p>
|
||||
) : null}
|
||||
<Input label="用户名/登录账号" onChange={(event) => setLogin(event.target.value)} placeholder="请输入用户名、邮箱或手机号" value={login} />
|
||||
<Input label="密码" onChange={(event) => setPassword(event.target.value)} placeholder="请输入密码" type="password" value={password} />
|
||||
<div className="login-captcha-row">
|
||||
|
||||
Reference in New Issue
Block a user