mirror of
https://github.com/logto-io/logto.git
synced 2024-12-30 20:33:54 -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": {
|
||||
"@fontsource/roboto-mono": "^4.5.7",
|
||||
"@logto/phrases": "^0.1.0",
|
||||
"@logto/react": "^0.1.15",
|
||||
"@logto/react": "^0.1.17",
|
||||
"@logto/schemas": "^0.1.0",
|
||||
"@logto/shared": "^0.1.0",
|
||||
"@mdx-js/react": "^1.6.22",
|
||||
|
|
|
@ -13,7 +13,7 @@ import UserInfoSkeleton from '../UserInfoSkeleton';
|
|||
import * as styles from './index.module.scss';
|
||||
|
||||
const UserInfo = () => {
|
||||
const { isAuthenticated, fetchUserInfo, signOut } = useLogto();
|
||||
const { isAuthenticated, getIdTokenClaims, signOut } = useLogto();
|
||||
const api = useApi();
|
||||
const { t } = useTranslation(undefined, { keyPrefix: 'admin_console' });
|
||||
const anchorRef = useRef<HTMLDivElement>(null);
|
||||
|
@ -24,11 +24,11 @@ const UserInfo = () => {
|
|||
useEffect(() => {
|
||||
(async () => {
|
||||
if (isAuthenticated) {
|
||||
const userInfo = await fetchUserInfo();
|
||||
const userInfo = getIdTokenClaims();
|
||||
setUser(userInfo);
|
||||
}
|
||||
})();
|
||||
}, [api, isAuthenticated, fetchUserInfo]);
|
||||
}, [api, isAuthenticated, getIdTokenClaims]);
|
||||
|
||||
if (!user) {
|
||||
return <UserInfoSkeleton />;
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
},
|
||||
"devDependencies": {
|
||||
"@logto/phrases": "^0.1.0",
|
||||
"@logto/react": "^0.1.15",
|
||||
"@logto/react": "^0.1.17",
|
||||
"@logto/schemas": "^0.1.0",
|
||||
"@logto/shared": "^0.1.0",
|
||||
"@parcel/core": "2.6.2",
|
||||
|
|
|
@ -13,7 +13,7 @@ import initI18n from './i18n/init';
|
|||
void initI18n();
|
||||
|
||||
const Main = () => {
|
||||
const { isAuthenticated, fetchUserInfo, signIn, signOut } = useLogto();
|
||||
const { isAuthenticated, getIdTokenClaims, signIn, signOut } = useLogto();
|
||||
const [user, setUser] = useState<UserInfoResponse>();
|
||||
const { t } = useTranslation(undefined, { keyPrefix: 'demo_app' });
|
||||
const isInCallback = Boolean(new URL(window.location.href).searchParams.get('code'));
|
||||
|
@ -27,13 +27,13 @@ const Main = () => {
|
|||
|
||||
if (isAuthenticated) {
|
||||
(async () => {
|
||||
const userInfo = await fetchUserInfo();
|
||||
const userInfo = getIdTokenClaims();
|
||||
setUser(userInfo);
|
||||
})();
|
||||
} else {
|
||||
void signIn(window.location.href);
|
||||
}
|
||||
}, [fetchUserInfo, isAuthenticated, isInCallback, signIn, t]);
|
||||
}, [getIdTokenClaims, isAuthenticated, isInCallback, signIn, t]);
|
||||
|
||||
useEffect(() => {
|
||||
const onThemeChange = (event: MediaQueryListEvent) => {
|
||||
|
|
413
pnpm-lock.yaml
413
pnpm-lock.yaml
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue