Page MenuHomePhabricator

D10909.diff
No OneTemporary

D10909.diff

diff --git a/lib/hooks/account-hooks.js b/lib/hooks/account-hooks.js
--- a/lib/hooks/account-hooks.js
+++ b/lib/hooks/account-hooks.js
@@ -1,5 +1,9 @@
// @flow
+import * as React from 'react';
+
+import type { AuthMetadata } from '../shared/identity-client-context.js';
+import { IdentityClientContext } from '../shared/identity-client-context.js';
import type { LoggedInUserInfo } from '../types/user-types.js';
import { useSelector } from '../utils/redux-utils.js';
@@ -11,4 +15,25 @@
);
}
-export { useLoggedInUserInfo };
+function useCommServicesAuthMetadata(): ?AuthMetadata {
+ const identityContext = React.useContext(IdentityClientContext);
+
+ const [authMetadata, setAuthMetadata] = React.useState<AuthMetadata | null>(
+ null,
+ );
+
+ React.useEffect(() => {
+ void (async () => {
+ try {
+ const metadata = await identityContext?.getAuthMetadata();
+ setAuthMetadata(metadata ?? null);
+ } catch {
+ setAuthMetadata(null);
+ }
+ })();
+ }, [identityContext]);
+
+ return authMetadata;
+}
+
+export { useLoggedInUserInfo, useCommServicesAuthMetadata };

File Metadata

Mime Type
text/plain
Expires
Fri, Jan 10, 7:03 AM (13 h, 48 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2846171
Default Alt Text
D10909.diff (1 KB)

Event Timeline