feat: configure Logto scopes and externalize appId

- Add 'admin' scope to Logto configuration in frontend.tsx.
- Externalize Logto appId to common.ts utils for better configuration management.
- Remove `isAuthExpired` check in UserCenter.tsx and always show the "Re-login" button.
This commit is contained in:
kyuuseiryuu 2026-03-16 14:30:23 +09:00
parent 1b01cff7d7
commit 2d928ab1e3
3 changed files with 12 additions and 10 deletions

View File

@ -13,14 +13,17 @@ import { RouterProvider } from "react-router";
import { LogtoProvider, type LogtoConfig } from '@logto/react';
import { route } from "./routes";
import { LOGTO_RESOURCE } from "./utils/constants";
import { LOGTO_DOMAIN } from "./utils/common";
import { LOGTO_APPID, LOGTO_DOMAIN } from "./utils/common";
const elem = document.getElementById("root")!;
const config: LogtoConfig = {
endpoint: LOGTO_DOMAIN,
appId: 'iq0oceaeqazpcned7hzil',
appId: LOGTO_APPID,
resources: [LOGTO_RESOURCE],
scopes: [
'admin',
]
};
const app = (
<StrictMode>

View File

@ -20,7 +20,7 @@ const redirect = encodeURIComponent(USER_CENTER_URL);
export const UserCenter = () => {
const { signIn, isAuthenticated, signOut, getIdTokenClaims } = useLogto();
const { isAuthExpired, autoSignIn } = useAutoLogin();
const { autoSignIn } = useAutoLogin();
const [user, setUser] = useState<IdTokenClaims>();
const navigate = useNavigate();
const location = useLocation();
@ -75,13 +75,11 @@ export const UserCenter = () => {
<Button block type="primary" onClick={() => navigate('/')} icon={<HomeOutlined />}></Button>
<Divider />
<Flex align="center" justify="center" style={{ width: '100%' }} gap={12}>
{isAuthExpired && (
<Flex flex={1}>
<Button block icon={<ReloadOutlined />} onClick={() => autoSignIn()}>
</Button>
</Flex>
)}
<Flex flex={1}>
<Button
block

View File

@ -2,6 +2,7 @@ import { chunk } from "lodash";
export const KAIQIU_BASE_URL = `https://kaiqiuwang.cc`;
export const LOGTO_DOMAIN = 'https://logto.ksr.la';
export const LOGTO_APPID = 'iq0oceaeqazpcned7hzil';
export function sneckGroup(size: number, groupLen: number) {
const indexArray = new Array<number>(size).fill(0).map((_, i) => i);