This repository has been archived by the owner on Jul 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
ManageAccessKeys.tsx
76 lines (71 loc) · 1.68 KB
/
ManageAccessKeys.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import type { UserResponse } from '@descope/web-js-sdk';
import React, { useCallback } from 'react';
import { Link } from 'react-router-dom';
import { useDescope, useUser, AccessKeyManagement } from '../../src';
const getUserDisplayName = (user?: UserResponse) =>
user?.name || user?.loginIds?.[0] || '';
const ManageAccessKeys = () => {
// useUser retrieves the logged in user information
const { user } = useUser();
// useDescope retrieves Descope SDK for further operations related to authentication
// such as logout
const sdk = useDescope();
const onLogout = useCallback(() => {
sdk.logout();
}, [sdk]);
return (
<>
<header
style={{
borderBottom: '1px solid gray',
display: 'flex',
justifyContent: 'space-between'
}}
>
<p>
<a href="/">Home</a>
</p>
<div>
<p>
User:{' '}
<span style={{ fontWeight: 'bold' }}>
{getUserDisplayName(user)}
</span>
</p>
<p>
<button
type="button"
id="logout-button"
onClick={onLogout}
style={{
display: 'block',
marginLeft: 'auto',
padding: 5
}}
>
Logout
</button>
</p>
<p>
{process.env.DESCOPE_STEP_UP_FLOW_ID && (
<Link id="step-up-button" to="/step-up">
Step Up
</Link>
)}
</p>
</div>
</header>
<h2>Manage Access Keys</h2>
<AccessKeyManagement
widgetId="access-key-management-widget"
tenant={process.env.DESCOPE_TENANT_ID}
/>
<h2>Manage My Access Keys</h2>
<AccessKeyManagement
widgetId="user-access-key-management-widget"
tenant={process.env.DESCOPE_TENANT_ID}
/>
</>
);
};
export default ManageAccessKeys;