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:
parent
1b01cff7d7
commit
2d928ab1e3
@ -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>
|
||||
|
||||
@ -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 icon={<ReloadOutlined />} onClick={() => autoSignIn()}>
|
||||
重新登陆
|
||||
</Button>
|
||||
</Flex>
|
||||
<Flex flex={1}>
|
||||
<Button
|
||||
block
|
||||
|
||||
@ -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);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user