mirror of
https://github.com/logto-io/logto.git
synced 2025-01-13 21:30:30 -05:00
refactor: bump react sdk 0.1.17 and remove fetchUserInfo call
This commit is contained in:
parent
e56c8f45e6
commit
a6a6cef15d
5 changed files with 307 additions and 122 deletions
|
@ -18,7 +18,7 @@
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@fontsource/roboto-mono": "^4.5.7",
|
"@fontsource/roboto-mono": "^4.5.7",
|
||||||
"@logto/phrases": "^0.1.0",
|
"@logto/phrases": "^0.1.0",
|
||||||
"@logto/react": "^0.1.15",
|
"@logto/react": "^0.1.17",
|
||||||
"@logto/schemas": "^0.1.0",
|
"@logto/schemas": "^0.1.0",
|
||||||
"@logto/shared": "^0.1.0",
|
"@logto/shared": "^0.1.0",
|
||||||
"@mdx-js/react": "^1.6.22",
|
"@mdx-js/react": "^1.6.22",
|
||||||
|
|
|
@ -13,7 +13,7 @@ import UserInfoSkeleton from '../UserInfoSkeleton';
|
||||||
import * as styles from './index.module.scss';
|
import * as styles from './index.module.scss';
|
||||||
|
|
||||||
const UserInfo = () => {
|
const UserInfo = () => {
|
||||||
const { isAuthenticated, fetchUserInfo, signOut } = useLogto();
|
const { isAuthenticated, getIdTokenClaims, signOut } = useLogto();
|
||||||
const api = useApi();
|
const api = useApi();
|
||||||
const { t } = useTranslation(undefined, { keyPrefix: 'admin_console' });
|
const { t } = useTranslation(undefined, { keyPrefix: 'admin_console' });
|
||||||
const anchorRef = useRef<HTMLDivElement>(null);
|
const anchorRef = useRef<HTMLDivElement>(null);
|
||||||
|
@ -24,11 +24,11 @@ const UserInfo = () => {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
(async () => {
|
(async () => {
|
||||||
if (isAuthenticated) {
|
if (isAuthenticated) {
|
||||||
const userInfo = await fetchUserInfo();
|
const userInfo = getIdTokenClaims();
|
||||||
setUser(userInfo);
|
setUser(userInfo);
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
}, [api, isAuthenticated, fetchUserInfo]);
|
}, [api, isAuthenticated, getIdTokenClaims]);
|
||||||
|
|
||||||
if (!user) {
|
if (!user) {
|
||||||
return <UserInfoSkeleton />;
|
return <UserInfoSkeleton />;
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@logto/phrases": "^0.1.0",
|
"@logto/phrases": "^0.1.0",
|
||||||
"@logto/react": "^0.1.15",
|
"@logto/react": "^0.1.17",
|
||||||
"@logto/schemas": "^0.1.0",
|
"@logto/schemas": "^0.1.0",
|
||||||
"@logto/shared": "^0.1.0",
|
"@logto/shared": "^0.1.0",
|
||||||
"@parcel/core": "2.6.2",
|
"@parcel/core": "2.6.2",
|
||||||
|
|
|
@ -13,7 +13,7 @@ import initI18n from './i18n/init';
|
||||||
void initI18n();
|
void initI18n();
|
||||||
|
|
||||||
const Main = () => {
|
const Main = () => {
|
||||||
const { isAuthenticated, fetchUserInfo, signIn, signOut } = useLogto();
|
const { isAuthenticated, getIdTokenClaims, signIn, signOut } = useLogto();
|
||||||
const [user, setUser] = useState<UserInfoResponse>();
|
const [user, setUser] = useState<UserInfoResponse>();
|
||||||
const { t } = useTranslation(undefined, { keyPrefix: 'demo_app' });
|
const { t } = useTranslation(undefined, { keyPrefix: 'demo_app' });
|
||||||
const isInCallback = Boolean(new URL(window.location.href).searchParams.get('code'));
|
const isInCallback = Boolean(new URL(window.location.href).searchParams.get('code'));
|
||||||
|
@ -27,13 +27,13 @@ const Main = () => {
|
||||||
|
|
||||||
if (isAuthenticated) {
|
if (isAuthenticated) {
|
||||||
(async () => {
|
(async () => {
|
||||||
const userInfo = await fetchUserInfo();
|
const userInfo = getIdTokenClaims();
|
||||||
setUser(userInfo);
|
setUser(userInfo);
|
||||||
})();
|
})();
|
||||||
} else {
|
} else {
|
||||||
void signIn(window.location.href);
|
void signIn(window.location.href);
|
||||||
}
|
}
|
||||||
}, [fetchUserInfo, isAuthenticated, isInCallback, signIn, t]);
|
}, [getIdTokenClaims, isAuthenticated, isInCallback, signIn, t]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const onThemeChange = (event: MediaQueryListEvent) => {
|
const onThemeChange = (event: MediaQueryListEvent) => {
|
||||||
|
|
413
pnpm-lock.yaml
generated
413
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue