-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathApp.js
More file actions
56 lines (52 loc) · 1.4 KB
/
Copy pathApp.js
File metadata and controls
56 lines (52 loc) · 1.4 KB
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
import React, {useEffect, useState} from 'react';
import {SafeAreaView, StyleSheet, View, Text} from 'react-native';
import {Auth} from 'aws-amplify';
import {withAuthenticator} from 'aws-amplify-react-native';
// after confirmation, the tenant custom attribute
// will appear in the id token
async function fetchUserInfo(setTenant) {
// get the id token of the signed in user
const {idToken} = await Auth.currentSession();
// get the tenant custom attribute from the id token
const tenant = idToken.payload['custom:tenant'];
setTenant(tenant);
}
const App = withAuthenticator(() => {
const [tenant, setTenant] = useState('');
useEffect(() => {
fetchUserInfo(setTenant);
}, []);
return (
<SafeAreaView>
<View style={styles.body}>
<View style={styles.sectionContainer}>
<Text style={styles.sectionTitle}>
AWS Amplify Multi-Tenancy Example
</Text>
<Text style={styles.sectionDescription}>Your tenant is {tenant}</Text>
</View>
</View>
</SafeAreaView>
);
});
const styles = StyleSheet.create({
body: {
backgroundColor: 'white',
},
sectionContainer: {
marginTop: 32,
paddingHorizontal: 24,
},
sectionTitle: {
fontSize: 24,
fontWeight: '600',
color: 'black',
},
sectionDescription: {
marginTop: 8,
fontSize: 18,
fontWeight: '400',
color: 'black',
},
});
export default App;