Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3736942
D10909.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D10909.diff
View Options
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
Details
Attached
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)
Attached To
Mode
D10909: [lib] Add hook for easy access to CSAT
Attached
Detach File
Event Timeline
Log In to Comment