be-components 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/ApiOverrides/index.js +179 -0
- package/lib/commonjs/ApiOverrides/index.js.map +1 -0
- package/lib/commonjs/ApiOverrides/types.d.js.map +1 -0
- package/lib/commonjs/Assets/images/powered_by_be.webp +0 -0
- package/lib/commonjs/Authenticator/Components/LoginForm.js +491 -0
- package/lib/commonjs/Authenticator/Components/LoginForm.js.map +1 -0
- package/lib/commonjs/{AuthenticateWizard → Authenticator}/Components/StrategyForm.js +81 -58
- package/lib/commonjs/Authenticator/Components/StrategyForm.js.map +1 -0
- package/lib/commonjs/{AuthenticateWizard → Authenticator}/api/index.js +31 -36
- package/lib/commonjs/Authenticator/api/index.js.map +1 -0
- package/lib/commonjs/Authenticator/api/types.d.js +2 -0
- package/lib/commonjs/Authenticator/api/types.d.js.map +1 -0
- package/lib/commonjs/{AuthenticateWizard → Authenticator}/index.js +69 -25
- package/lib/commonjs/Authenticator/index.js.map +1 -0
- package/lib/commonjs/Components/Button.js +1 -1
- package/lib/commonjs/Components/Button.js.map +1 -1
- package/lib/commonjs/Components/Icons.js +115 -0
- package/lib/commonjs/Components/Icons.js.map +1 -1
- package/lib/commonjs/Components/ImageUploader.js +86 -0
- package/lib/commonjs/Components/ImageUploader.js.map +1 -0
- package/lib/commonjs/Components/Spring.js +16 -6
- package/lib/commonjs/Components/Spring.js.map +1 -1
- package/lib/commonjs/Components/TextInput.js +9 -3
- package/lib/commonjs/Components/TextInput.js.map +1 -1
- package/lib/commonjs/Font.css +4 -4
- package/lib/commonjs/ProfileManager/Components/BasicInfoManager.js +250 -0
- package/lib/commonjs/ProfileManager/Components/BasicInfoManager.js.map +1 -0
- package/lib/commonjs/ProfileManager/Components/BasicStatus.js +135 -0
- package/lib/commonjs/ProfileManager/Components/BasicStatus.js.map +1 -0
- package/lib/commonjs/ProfileManager/Components/CodeRedeem.js +361 -0
- package/lib/commonjs/ProfileManager/Components/CodeRedeem.js.map +1 -0
- package/lib/commonjs/ProfileManager/Components/DOBManager.js +195 -0
- package/lib/commonjs/ProfileManager/Components/DOBManager.js.map +1 -0
- package/lib/commonjs/ProfileManager/Components/EmailManager.js +287 -0
- package/lib/commonjs/ProfileManager/Components/EmailManager.js.map +1 -0
- package/lib/commonjs/ProfileManager/Components/PasswordManager.js +334 -0
- package/lib/commonjs/ProfileManager/Components/PasswordManager.js.map +1 -0
- package/lib/commonjs/ProfileManager/Components/PhoneManager.js +291 -0
- package/lib/commonjs/ProfileManager/Components/PhoneManager.js.map +1 -0
- package/lib/commonjs/ProfileManager/Components/ProfilePicManager.js +114 -0
- package/lib/commonjs/ProfileManager/Components/ProfilePicManager.js.map +1 -0
- package/lib/commonjs/ProfileManager/Components/ProfileWelcome.js +80 -0
- package/lib/commonjs/ProfileManager/Components/ProfileWelcome.js.map +1 -0
- package/lib/commonjs/ProfileManager/Components/ProfileWizard.js +545 -0
- package/lib/commonjs/ProfileManager/Components/ProfileWizard.js.map +1 -0
- package/lib/commonjs/ProfileManager/Components/VouchCard.js +454 -0
- package/lib/commonjs/ProfileManager/Components/VouchCard.js.map +1 -0
- package/lib/commonjs/ProfileManager/api/index.js +400 -0
- package/lib/commonjs/ProfileManager/api/index.js.map +1 -0
- package/lib/commonjs/ProfileManager/api/types.d.js +2 -0
- package/lib/commonjs/ProfileManager/api/types.d.js.map +1 -0
- package/lib/commonjs/ProfileManager/index.js +128 -0
- package/lib/commonjs/ProfileManager/index.js.map +1 -0
- package/lib/commonjs/constants/styles.js +10 -0
- package/lib/commonjs/constants/styles.js.map +1 -1
- package/lib/commonjs/index.js +24 -10
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/ApiOverrides/index.js +173 -0
- package/lib/module/ApiOverrides/index.js.map +1 -0
- package/lib/module/ApiOverrides/types.d.js.map +1 -0
- package/lib/module/Assets/images/powered_by_be.webp +0 -0
- package/lib/module/Authenticator/Components/LoginForm.js +482 -0
- package/lib/module/Authenticator/Components/LoginForm.js.map +1 -0
- package/lib/module/{AuthenticateWizard → Authenticator}/Components/StrategyForm.js +82 -59
- package/lib/module/Authenticator/Components/StrategyForm.js.map +1 -0
- package/lib/module/{AuthenticateWizard → Authenticator}/api/index.js +31 -36
- package/lib/module/Authenticator/api/index.js.map +1 -0
- package/lib/module/Authenticator/api/types.d.js +2 -0
- package/lib/module/Authenticator/api/types.d.js.map +1 -0
- package/lib/module/Authenticator/index.js +121 -0
- package/lib/module/Authenticator/index.js.map +1 -0
- package/lib/module/Components/Button.js +1 -1
- package/lib/module/Components/Button.js.map +1 -1
- package/lib/module/Components/Icons.js +115 -0
- package/lib/module/Components/Icons.js.map +1 -1
- package/lib/module/Components/ImageUploader.js +78 -0
- package/lib/module/Components/ImageUploader.js.map +1 -0
- package/lib/module/Components/Spring.js +17 -7
- package/lib/module/Components/Spring.js.map +1 -1
- package/lib/module/Components/TextInput.js +9 -3
- package/lib/module/Components/TextInput.js.map +1 -1
- package/lib/module/Font.css +4 -4
- package/lib/module/ProfileManager/Components/BasicInfoManager.js +241 -0
- package/lib/module/ProfileManager/Components/BasicInfoManager.js.map +1 -0
- package/lib/module/ProfileManager/Components/BasicStatus.js +128 -0
- package/lib/module/ProfileManager/Components/BasicStatus.js.map +1 -0
- package/lib/module/ProfileManager/Components/CodeRedeem.js +352 -0
- package/lib/module/ProfileManager/Components/CodeRedeem.js.map +1 -0
- package/lib/module/ProfileManager/Components/DOBManager.js +186 -0
- package/lib/module/ProfileManager/Components/DOBManager.js.map +1 -0
- package/lib/module/ProfileManager/Components/EmailManager.js +278 -0
- package/lib/module/ProfileManager/Components/EmailManager.js.map +1 -0
- package/lib/module/ProfileManager/Components/PasswordManager.js +325 -0
- package/lib/module/ProfileManager/Components/PasswordManager.js.map +1 -0
- package/lib/module/ProfileManager/Components/PhoneManager.js +282 -0
- package/lib/module/ProfileManager/Components/PhoneManager.js.map +1 -0
- package/lib/module/ProfileManager/Components/ProfilePicManager.js +107 -0
- package/lib/module/ProfileManager/Components/ProfilePicManager.js.map +1 -0
- package/lib/module/ProfileManager/Components/ProfileWelcome.js +73 -0
- package/lib/module/ProfileManager/Components/ProfileWelcome.js.map +1 -0
- package/lib/module/ProfileManager/Components/ProfileWizard.js +537 -0
- package/lib/module/ProfileManager/Components/ProfileWizard.js.map +1 -0
- package/lib/module/ProfileManager/Components/VouchCard.js +445 -0
- package/lib/module/ProfileManager/Components/VouchCard.js.map +1 -0
- package/lib/module/ProfileManager/api/index.js +394 -0
- package/lib/module/ProfileManager/api/index.js.map +1 -0
- package/lib/module/ProfileManager/api/types.d.js +2 -0
- package/lib/module/ProfileManager/api/types.d.js.map +1 -0
- package/lib/module/ProfileManager/index.js +119 -0
- package/lib/module/ProfileManager/index.js.map +1 -0
- package/lib/module/constants/styles.js +10 -0
- package/lib/module/constants/styles.js.map +1 -1
- package/lib/module/index.js +7 -3
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/ApiOverrides/index.d.ts +24 -0
- package/lib/typescript/src/ApiOverrides/index.d.ts.map +1 -0
- package/lib/typescript/src/Authenticator/Components/LoginForm.d.ts +10 -0
- package/lib/typescript/src/Authenticator/Components/LoginForm.d.ts.map +1 -0
- package/lib/typescript/src/{AuthenticateWizard → Authenticator}/Components/StrategyForm.d.ts +2 -1
- package/lib/typescript/src/Authenticator/Components/StrategyForm.d.ts.map +1 -0
- package/lib/typescript/src/{AuthenticateWizard → Authenticator}/api/index.d.ts +16 -8
- package/lib/typescript/src/Authenticator/api/index.d.ts.map +1 -0
- package/lib/typescript/src/Authenticator/index.d.ts +16 -0
- package/lib/typescript/src/Authenticator/index.d.ts.map +1 -0
- package/lib/typescript/src/Components/Icons.d.ts +3 -0
- package/lib/typescript/src/Components/Icons.d.ts.map +1 -1
- package/lib/typescript/src/Components/ImageUploader.d.ts +11 -0
- package/lib/typescript/src/Components/ImageUploader.d.ts.map +1 -0
- package/lib/typescript/src/Components/Spring.d.ts +2 -1
- package/lib/typescript/src/Components/Spring.d.ts.map +1 -1
- package/lib/typescript/src/Components/TextInput.d.ts +4 -1
- package/lib/typescript/src/Components/TextInput.d.ts.map +1 -1
- package/lib/typescript/src/ProfileManager/Components/BasicInfoManager.d.ts +12 -0
- package/lib/typescript/src/ProfileManager/Components/BasicInfoManager.d.ts.map +1 -0
- package/lib/typescript/src/ProfileManager/Components/BasicStatus.d.ts +10 -0
- package/lib/typescript/src/ProfileManager/Components/BasicStatus.d.ts.map +1 -0
- package/lib/typescript/src/ProfileManager/Components/CodeRedeem.d.ts +11 -0
- package/lib/typescript/src/ProfileManager/Components/CodeRedeem.d.ts.map +1 -0
- package/lib/typescript/src/ProfileManager/Components/DOBManager.d.ts +12 -0
- package/lib/typescript/src/ProfileManager/Components/DOBManager.d.ts.map +1 -0
- package/lib/typescript/src/ProfileManager/Components/EmailManager.d.ts +12 -0
- package/lib/typescript/src/ProfileManager/Components/EmailManager.d.ts.map +1 -0
- package/lib/typescript/src/ProfileManager/Components/PasswordManager.d.ts +12 -0
- package/lib/typescript/src/ProfileManager/Components/PasswordManager.d.ts.map +1 -0
- package/lib/typescript/src/ProfileManager/Components/PhoneManager.d.ts +12 -0
- package/lib/typescript/src/ProfileManager/Components/PhoneManager.d.ts.map +1 -0
- package/lib/typescript/src/ProfileManager/Components/ProfilePicManager.d.ts +12 -0
- package/lib/typescript/src/ProfileManager/Components/ProfilePicManager.d.ts.map +1 -0
- package/lib/typescript/src/ProfileManager/Components/ProfileWelcome.d.ts +11 -0
- package/lib/typescript/src/ProfileManager/Components/ProfileWelcome.d.ts.map +1 -0
- package/lib/typescript/src/ProfileManager/Components/ProfileWizard.d.ts +14 -0
- package/lib/typescript/src/ProfileManager/Components/ProfileWizard.d.ts.map +1 -0
- package/lib/typescript/src/ProfileManager/Components/VouchCard.d.ts +9 -0
- package/lib/typescript/src/ProfileManager/Components/VouchCard.d.ts.map +1 -0
- package/lib/typescript/src/ProfileManager/api/index.d.ts +104 -0
- package/lib/typescript/src/ProfileManager/api/index.d.ts.map +1 -0
- package/lib/typescript/src/ProfileManager/index.d.ts +11 -0
- package/lib/typescript/src/ProfileManager/index.d.ts.map +1 -0
- package/lib/typescript/src/constants/styles.d.ts +10 -0
- package/lib/typescript/src/constants/styles.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +7 -3
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/package.json +7 -2
- package/src/ApiOverrides/index.ts +135 -0
- package/src/ApiOverrides/types.d.ts +7 -0
- package/src/Assets/images/powered_by_be.webp +0 -0
- package/src/Authenticator/Components/LoginForm.tsx +298 -0
- package/src/{AuthenticateWizard → Authenticator}/Components/StrategyForm.tsx +54 -40
- package/src/{AuthenticateWizard → Authenticator}/api/index.ts +27 -31
- package/src/{AuthenticateWizard → Authenticator}/api/types.d.ts +11 -28
- package/src/Authenticator/index.tsx +109 -0
- package/src/Components/Button.tsx +1 -1
- package/src/Components/Icons.tsx +59 -0
- package/src/Components/ImageUploader.tsx +104 -0
- package/src/Components/Spring.tsx +16 -11
- package/src/Components/TextInput.tsx +9 -3
- package/src/Font.css +4 -4
- package/src/ProfileManager/Components/BasicInfoManager.tsx +157 -0
- package/src/ProfileManager/Components/BasicStatus.tsx +81 -0
- package/src/ProfileManager/Components/CodeRedeem.tsx +234 -0
- package/src/ProfileManager/Components/DOBManager.tsx +154 -0
- package/src/ProfileManager/Components/EmailManager.tsx +205 -0
- package/src/ProfileManager/Components/PasswordManager.tsx +198 -0
- package/src/ProfileManager/Components/PhoneManager.tsx +210 -0
- package/src/ProfileManager/Components/ProfilePicManager.tsx +81 -0
- package/src/ProfileManager/Components/ProfileWelcome.tsx +53 -0
- package/src/ProfileManager/Components/ProfileWizard.tsx +385 -0
- package/src/ProfileManager/Components/VouchCard.tsx +265 -0
- package/src/ProfileManager/api/index.ts +250 -0
- package/src/ProfileManager/api/types.d.ts +138 -0
- package/src/ProfileManager/index.tsx +84 -0
- package/src/constants/styles.ts +10 -0
- package/src/index.tsx +12 -6
- package/lib/commonjs/AuthenticateWizard/Components/StrategyForm.js.map +0 -1
- package/lib/commonjs/AuthenticateWizard/api/index.js.map +0 -1
- package/lib/commonjs/AuthenticateWizard/api/types.d.js.map +0 -1
- package/lib/commonjs/AuthenticateWizard/index.js.map +0 -1
- package/lib/module/AuthenticateWizard/Components/StrategyForm.js.map +0 -1
- package/lib/module/AuthenticateWizard/api/index.js.map +0 -1
- package/lib/module/AuthenticateWizard/api/types.d.js.map +0 -1
- package/lib/module/AuthenticateWizard/index.js +0 -77
- package/lib/module/AuthenticateWizard/index.js.map +0 -1
- package/lib/typescript/src/AuthenticateWizard/Components/StrategyForm.d.ts.map +0 -1
- package/lib/typescript/src/AuthenticateWizard/api/index.d.ts.map +0 -1
- package/lib/typescript/src/AuthenticateWizard/index.d.ts +0 -15
- package/lib/typescript/src/AuthenticateWizard/index.d.ts.map +0 -1
- package/src/AuthenticateWizard/index.tsx +0 -84
- /package/lib/commonjs/{AuthenticateWizard/api → ApiOverrides}/types.d.js +0 -0
- /package/lib/commonjs/{fonts → Assets/fonts}/Barlow-Bold.ttf +0 -0
- /package/lib/commonjs/{fonts → Assets/fonts}/Barlow-Light.ttf +0 -0
- /package/lib/commonjs/{fonts → Assets/fonts}/Barlow-Regular.ttf +0 -0
- /package/lib/commonjs/{fonts → Assets/fonts}/Barlow-SemiBold.ttf +0 -0
- /package/lib/module/{AuthenticateWizard/api → ApiOverrides}/types.d.js +0 -0
- /package/lib/module/{fonts → Assets/fonts}/Barlow-Bold.ttf +0 -0
- /package/lib/module/{fonts → Assets/fonts}/Barlow-Light.ttf +0 -0
- /package/lib/module/{fonts → Assets/fonts}/Barlow-Regular.ttf +0 -0
- /package/lib/module/{fonts → Assets/fonts}/Barlow-SemiBold.ttf +0 -0
- /package/src/{fonts → Assets/fonts}/Barlow-Bold.ttf +0 -0
- /package/src/{fonts → Assets/fonts}/Barlow-Light.ttf +0 -0
- /package/src/{fonts → Assets/fonts}/Barlow-Regular.ttf +0 -0
- /package/src/{fonts → Assets/fonts}/Barlow-SemiBold.ttf +0 -0
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
2
|
+
import axios from 'axios';
|
|
3
|
+
import moment from 'moment-mini';
|
|
4
|
+
import { v4 } from 'uuid';
|
|
5
|
+
import type { AuthStateProps } from './types';
|
|
6
|
+
|
|
7
|
+
const ENVIRONMENT_ENDPOINTS = {
|
|
8
|
+
DEVELOPMENT: {
|
|
9
|
+
AUTH_SVC_API: 'http://localhost:5000',
|
|
10
|
+
VOUCH_ID: 'adqEZph8t*_NBFy6u_l4!t~Hin6kpK'
|
|
11
|
+
},
|
|
12
|
+
STAGING: {
|
|
13
|
+
AUTH_SVC_API: 'https://stage-be-auth-svc.herokuapp.com',
|
|
14
|
+
VOUCH_ID: 'adqEZph8t*_NBFy6u_l4!t~Hin6kpK'
|
|
15
|
+
},
|
|
16
|
+
PRODUCTION: {
|
|
17
|
+
AUTH_SVC_API: 'https://api.players.bettoredge.com',
|
|
18
|
+
VOUCH_ID: 'Q3tmJ3r9FnkN*n-MqS-!j0NS*k!mdo'
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
let ENDPOINTS:{ [key:string]: string } = {}
|
|
23
|
+
|
|
24
|
+
let auth_state:AuthStateProps = {
|
|
25
|
+
authenticated:false,
|
|
26
|
+
distinct_id: ''
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export { APIOverrides }
|
|
30
|
+
|
|
31
|
+
const APIOverrides = {
|
|
32
|
+
start: async(env:'PRODUCTION'|'STAGING'|'DEVELOPMENT', no_cache?:boolean):Promise<{ authenticated:boolean, access_token?:string, refresh_token?:string, expire_datetime?:any, distinct_id:string }> => {
|
|
33
|
+
APIOverrides.setEnvironment(env);
|
|
34
|
+
let distinct_id = await APIOverrides.getDistinctID();
|
|
35
|
+
auth_state = { authenticated: false, distinct_id }
|
|
36
|
+
if(no_cache){ return auth_state }
|
|
37
|
+
let cached_token = await AsyncStorage.getItem('access_token');
|
|
38
|
+
if(!cached_token){ return { authenticated: false, distinct_id } }
|
|
39
|
+
let cached_refresh_token = await AsyncStorage.getItem('refresh_token');
|
|
40
|
+
if(!cached_refresh_token){ return { authenticated: false, distinct_id } }
|
|
41
|
+
let expire_datetime = await AsyncStorage.getItem('auth_expire_time');
|
|
42
|
+
if(!expire_datetime){ return { authenticated:false, distinct_id } }
|
|
43
|
+
if(moment().isAfter(moment(expire_datetime))){
|
|
44
|
+
//Try to get a new one
|
|
45
|
+
const refresh_resp = await APIOverrides.refreshToken(cached_refresh_token, distinct_id);
|
|
46
|
+
if(!refresh_resp){
|
|
47
|
+
//This failed - so lets clear out our stored tokens
|
|
48
|
+
await AsyncStorage.removeItem('access_token');
|
|
49
|
+
await AsyncStorage.removeItem('refresh_token');
|
|
50
|
+
await AsyncStorage.removeItem('auth_expire_time');
|
|
51
|
+
return { authenticated: false, distinct_id }
|
|
52
|
+
}
|
|
53
|
+
cached_token = refresh_resp.access_token
|
|
54
|
+
cached_refresh_token = refresh_resp.refresh_token
|
|
55
|
+
expire_datetime = refresh_resp.expire_datetime
|
|
56
|
+
await AsyncStorage.setItem('access_token', cached_token);
|
|
57
|
+
await AsyncStorage.setItem('refresh_token', cached_refresh_token);
|
|
58
|
+
await AsyncStorage.setItem('auth_expire_time', expire_datetime);
|
|
59
|
+
}
|
|
60
|
+
APIOverrides.setBearerToken(cached_token);
|
|
61
|
+
APIOverrides.setRefreshTokenInterceptor(cached_refresh_token, distinct_id)
|
|
62
|
+
auth_state = {
|
|
63
|
+
authenticated: true,
|
|
64
|
+
distinct_id,
|
|
65
|
+
access_token: cached_token,
|
|
66
|
+
refresh_token: cached_refresh_token,
|
|
67
|
+
expire_datetime
|
|
68
|
+
}
|
|
69
|
+
return auth_state
|
|
70
|
+
},
|
|
71
|
+
setEnvironment: (env:'PRODUCTION'|'STAGING'|'DEVELOPMENT') => {
|
|
72
|
+
ENDPOINTS = ENVIRONMENT_ENDPOINTS[env]
|
|
73
|
+
},
|
|
74
|
+
getEndpoints: () => {
|
|
75
|
+
return ENDPOINTS
|
|
76
|
+
},
|
|
77
|
+
cacheTokens: async(access_token:string, refresh_token?:string, expire_datetime?:any) => {
|
|
78
|
+
await AsyncStorage.setItem('access_token', access_token);
|
|
79
|
+
if(refresh_token){ await AsyncStorage.setItem('refresh_token', refresh_token) }
|
|
80
|
+
if(expire_datetime){ await AsyncStorage.setItem('auth_expire_time', expire_datetime) }
|
|
81
|
+
},
|
|
82
|
+
getDistinctID: async() => {
|
|
83
|
+
let distinct_id = await AsyncStorage.getItem('distinct_id');
|
|
84
|
+
if(!distinct_id){
|
|
85
|
+
distinct_id = v4();
|
|
86
|
+
AsyncStorage.setItem('distinct_id', distinct_id);
|
|
87
|
+
}
|
|
88
|
+
return distinct_id
|
|
89
|
+
},
|
|
90
|
+
setBearerToken: (token?:string) => {
|
|
91
|
+
if (token) {
|
|
92
|
+
axios.defaults.headers.common['Authorization'] = `Bearer ${token}`;
|
|
93
|
+
} else {
|
|
94
|
+
delete axios.defaults.headers.common['Authorization'];
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
refreshToken: async(token:string, distinct_id:string):Promise<{refresh_token:string, access_token:string, expire_datetime:string } | undefined> => {
|
|
98
|
+
try {
|
|
99
|
+
let AUTH_SVC_API = ENDPOINTS['AUTH_SVC_API']
|
|
100
|
+
const resp = await axios.post(`${AUTH_SVC_API}/v1/players/tokens/token/refresh`, { refresh_token:token, device_id:distinct_id })
|
|
101
|
+
return resp.data
|
|
102
|
+
} catch (error) {
|
|
103
|
+
return undefined
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
},
|
|
107
|
+
setRefreshTokenInterceptor: async(token:string, distinct_id:string, cache?:boolean) => {
|
|
108
|
+
//Set the endpoint based on the environment that is past
|
|
109
|
+
axios.interceptors.response.use((response) => {
|
|
110
|
+
return response
|
|
111
|
+
}, async (error) => {
|
|
112
|
+
const originalRequest = error.config;
|
|
113
|
+
//If the user gets a 403 - sign them out if they haven't been signed out yet
|
|
114
|
+
if(error?.response?.status === 403) {
|
|
115
|
+
//if(store.getState().auth.isAuthenticated){ store.dispatch(auth_logout()); throw new Error(error); }
|
|
116
|
+
return Promise.reject({ message: 'Authenication session has expired.' })
|
|
117
|
+
}
|
|
118
|
+
//If the user gets a 401 - check for a refresh_token and attempt to get another access token to use the request
|
|
119
|
+
if(error?.response?.status === 401 && !originalRequest._retry) {
|
|
120
|
+
originalRequest._retry = true;
|
|
121
|
+
let refresh_resp = await APIOverrides.refreshToken(token, distinct_id);
|
|
122
|
+
if(!refresh_resp){
|
|
123
|
+
return Promise.reject({ message: 'Unable to authenticate request' })
|
|
124
|
+
}
|
|
125
|
+
const { access_token, refresh_token, expire_datetime } = refresh_resp;
|
|
126
|
+
APIOverrides.setBearerToken(access_token)
|
|
127
|
+
if(cache){
|
|
128
|
+
await APIOverrides.cacheTokens(access_token, refresh_token, expire_datetime);
|
|
129
|
+
}
|
|
130
|
+
return Promise.resolve(axios({ ...originalRequest, headers: { ...originalRequest.headers, Authorization: `Bearer ${access_token}` }}));
|
|
131
|
+
}
|
|
132
|
+
return Promise.reject(error)
|
|
133
|
+
})
|
|
134
|
+
}
|
|
135
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { View, TouchableOpacity } from "react-native"
|
|
3
|
+
import { Button, Icons, Text, TextInput } from '../../Components';
|
|
4
|
+
import Colors from '../../constants/colors';
|
|
5
|
+
import { AuthenticateApi, AuthenticateHelpers } from '../api';
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
type LoginFormProps = {
|
|
9
|
+
visible:boolean,
|
|
10
|
+
width:number,
|
|
11
|
+
onRegister: () => void,
|
|
12
|
+
onAuthenticated: (access_token:string, refresh_token:string, expire_datetime:any) => void
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
const attribute_options = ['username', 'email', 'phone']
|
|
17
|
+
const LoginForm = ({ width, visible, onRegister, onAuthenticated }:LoginFormProps) => {
|
|
18
|
+
const [ authenticated, setAuthenticated ] = useState(false);
|
|
19
|
+
const [ auth_check, setAuthCheck ] = useState<{
|
|
20
|
+
loading:boolean,
|
|
21
|
+
attribute: 'username'|'email'|'phone',
|
|
22
|
+
value:string
|
|
23
|
+
}>({
|
|
24
|
+
loading:false,
|
|
25
|
+
attribute:'username',
|
|
26
|
+
value:'james'
|
|
27
|
+
});
|
|
28
|
+
const [ halted, setHalted ] = useState(false);
|
|
29
|
+
const [ login_try, setLoginTry ] = useState<{
|
|
30
|
+
pass_token: string,
|
|
31
|
+
loading:boolean,
|
|
32
|
+
visible:boolean,
|
|
33
|
+
verification_session_id?:string,
|
|
34
|
+
type: 'token' | 'password',
|
|
35
|
+
error?:string
|
|
36
|
+
}>({
|
|
37
|
+
pass_token: '',
|
|
38
|
+
loading:false,
|
|
39
|
+
visible:false,
|
|
40
|
+
type: 'password'
|
|
41
|
+
})
|
|
42
|
+
const [ auth_check_error, setAuthCheckError ] = useState<string>();
|
|
43
|
+
|
|
44
|
+
const { loading, attribute, value } = auth_check
|
|
45
|
+
const { pass_token, type, verification_session_id } = login_try;
|
|
46
|
+
|
|
47
|
+
const handleAuthCheck = async() => {
|
|
48
|
+
console.log(authenticated)
|
|
49
|
+
if(loading){ return } //No mashy mashy
|
|
50
|
+
setAuthCheck({ ...auth_check, loading:true })
|
|
51
|
+
const { result, message, verification_session_id, next } = await AuthenticateApi.authCheck(attribute, value);
|
|
52
|
+
if(result == 'fail'){
|
|
53
|
+
setAuthCheckError(message)
|
|
54
|
+
} else {
|
|
55
|
+
setLoginTry({
|
|
56
|
+
pass_token: '',
|
|
57
|
+
verification_session_id: verification_session_id,
|
|
58
|
+
visible:true,
|
|
59
|
+
loading:false,
|
|
60
|
+
type: next ?? 'password'
|
|
61
|
+
})
|
|
62
|
+
}
|
|
63
|
+
setAuthCheck({ ...auth_check, loading:false })
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const handleForgot = async() => {
|
|
67
|
+
const resp = await AuthenticateApi.authForgot(attribute, value)
|
|
68
|
+
if(resp.result == 'fail'){
|
|
69
|
+
setAuthCheckError(resp.message)
|
|
70
|
+
} else {
|
|
71
|
+
setLoginTry({
|
|
72
|
+
pass_token: '',
|
|
73
|
+
verification_session_id: resp.verification_session_id,
|
|
74
|
+
visible:true,
|
|
75
|
+
loading:false,
|
|
76
|
+
type: resp.next ?? 'password'
|
|
77
|
+
})
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const handleLogin = async() => {
|
|
82
|
+
setLoginTry({ ...login_try, loading:true })
|
|
83
|
+
const { result, message, access_token, refresh_token, expire_datetime } = await AuthenticateApi.authLogin(attribute, value, pass_token, verification_session_id)
|
|
84
|
+
if(result == 'fail' || !access_token || !refresh_token){
|
|
85
|
+
setLoginTry({ ...login_try, error:message, loading:false })
|
|
86
|
+
setHalted(true)
|
|
87
|
+
return setTimeout(() => {
|
|
88
|
+
setHalted(false);
|
|
89
|
+
}, 5000);
|
|
90
|
+
}
|
|
91
|
+
setLoginTry({ ...login_try, loading:false, error:undefined })
|
|
92
|
+
setAuthenticated(true)
|
|
93
|
+
return onAuthenticated(access_token, refresh_token, expire_datetime)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const getAttributeIcon = () => {
|
|
97
|
+
switch(attribute){
|
|
98
|
+
case 'email': return <Icons.EmailIcon size={20} color={Colors.brand.midnight}/>
|
|
99
|
+
case 'phone': return <Icons.PhoneIcon size={20} color={Colors.brand.midnight} />
|
|
100
|
+
case 'username': return <Icons.UserIcon size={20} color={Colors.brand.midnight} />
|
|
101
|
+
default: return <Icons.UserIcon size={20} color={Colors.brand.midnight} />
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const { valid } = AuthenticateHelpers.isAttributeValid(attribute, value);
|
|
106
|
+
const login_valid = pass_token.length > 0 && !halted ? true : false;
|
|
107
|
+
|
|
108
|
+
if(!visible){ return <></> }
|
|
109
|
+
|
|
110
|
+
return (
|
|
111
|
+
<View style={{ flex:1, width }}>
|
|
112
|
+
{!login_try.visible ?
|
|
113
|
+
<View style={{ flex:1 }}>
|
|
114
|
+
<View style={{ padding:30 }}>
|
|
115
|
+
<View>
|
|
116
|
+
<Text size={18} color={Colors.brand.midnight} weight='bold'>Login Using My:</Text>
|
|
117
|
+
</View>
|
|
118
|
+
<View nativeID='attribute_toggle' style={{ marginTop:10, flexDirection:'row', borderRadius:22, borderWidth:1, backgroundColor:Colors.shades.shade400, borderColor:Colors.shades.shade600 }}>
|
|
119
|
+
{attribute_options.map((a,i) => {
|
|
120
|
+
const selected = a == attribute ? true : false
|
|
121
|
+
return (
|
|
122
|
+
<Button
|
|
123
|
+
style={{ flex:1 }}
|
|
124
|
+
title={a.toUpperCase()}
|
|
125
|
+
borderRadiusOverride={{
|
|
126
|
+
borderTopLeftRadius: i == 0 ? 22 : 0,
|
|
127
|
+
borderBottomLeftRadius: i == 0 ? 22 : 0,
|
|
128
|
+
borderTopRightRadius: i == attribute_options.length -1 ? 22 : 0,
|
|
129
|
+
borderBottomRightRadius: i == attribute_options.length -1 ? 22 : 0,
|
|
130
|
+
}}
|
|
131
|
+
title_color={selected ? Colors.shades.white : Colors.brand.electric}
|
|
132
|
+
padding={15}
|
|
133
|
+
title_weight={selected ? 'bold' : 'regular'}
|
|
134
|
+
backgroundColor={selected ? Colors.brand.electric : 'transparent'}
|
|
135
|
+
onPress={() => setAuthCheck({ attribute:a as 'username'|'email'|'phone', value: '', loading:false })}
|
|
136
|
+
/>
|
|
137
|
+
)
|
|
138
|
+
})}
|
|
139
|
+
</View>
|
|
140
|
+
</View>
|
|
141
|
+
<View style={{ flex:1 }}>
|
|
142
|
+
<View style={{ backgroundColor:Colors.shades.shade100, borderRadius:8, padding:30 }}>
|
|
143
|
+
<View style={{ marginBottom:10 }}>
|
|
144
|
+
<Text size={18} color={Colors.brand.midnight} weight='bold'>ENTER {attribute.toUpperCase()}</Text>
|
|
145
|
+
<Text style={{ marginTop:5 }} size={14} color={Colors.brand.midnight} weight='regular'>Please enter your {attribute} to continue.</Text>
|
|
146
|
+
</View>
|
|
147
|
+
<View style={{ marginTop:5, flexDirection:'row', alignItems:'center', borderRadius:22, borderWidth:1, borderColor:Colors.shades.shade600 }}>
|
|
148
|
+
<View style={{ paddingLeft:10, paddingRight:15 }}>
|
|
149
|
+
{getAttributeIcon()}
|
|
150
|
+
</View>
|
|
151
|
+
<TextInput
|
|
152
|
+
style={{ flex:1 }}
|
|
153
|
+
value={value}
|
|
154
|
+
placeholder={attribute.toUpperCase()}
|
|
155
|
+
autoFocus={true}
|
|
156
|
+
placeholderTextColor={Colors.brand.slate}
|
|
157
|
+
onChangeText={(text) => {
|
|
158
|
+
setAuthCheck({ ...auth_check, value: text })
|
|
159
|
+
}}
|
|
160
|
+
/>
|
|
161
|
+
<View style={{ padding:10 }}>
|
|
162
|
+
{ valid ?
|
|
163
|
+
<Icons.CheckCirlceIcon color={Colors.utility.success} size={14} />
|
|
164
|
+
:
|
|
165
|
+
<Icons.AlertIcon color={Colors.utility.warning} size={14} />
|
|
166
|
+
}
|
|
167
|
+
</View>
|
|
168
|
+
</View>
|
|
169
|
+
{auth_check_error ?
|
|
170
|
+
<TouchableOpacity style={{ marginTop:10, padding:10, backgroundColor:Colors.shades.white, borderRadius:8 }} onPress={() => onRegister()}>
|
|
171
|
+
<Text size={14} color={Colors.utility.error} weight='semibold' textAlign='center'>{auth_check_error}</Text>
|
|
172
|
+
<Text style={{ marginTop:5 }} size={14} color={Colors.brand.electric} weight='bold' textAlign='center'>SIGN UP HERE</Text>
|
|
173
|
+
</TouchableOpacity>
|
|
174
|
+
:<></>}
|
|
175
|
+
</View>
|
|
176
|
+
</View>
|
|
177
|
+
<View style={{ padding:20 }}>
|
|
178
|
+
<Button
|
|
179
|
+
title='LOGIN'
|
|
180
|
+
style={{ opacity:!valid||loading?0.5:1 }}
|
|
181
|
+
title_color={Colors.shades.white}
|
|
182
|
+
loading={loading}
|
|
183
|
+
backgroundColor={Colors.brand.electric}
|
|
184
|
+
disabled={!valid||loading}
|
|
185
|
+
padding={15}
|
|
186
|
+
onPress={() => handleAuthCheck()}
|
|
187
|
+
/>
|
|
188
|
+
</View>
|
|
189
|
+
<View style={{ padding:15, backgroundColor:Colors.shades.shade100 }}>
|
|
190
|
+
<Button
|
|
191
|
+
title='Are You New? Sign Up Here'
|
|
192
|
+
title_color={Colors.brand.electric}
|
|
193
|
+
backgroundColor='transparent'
|
|
194
|
+
onPress={() => onRegister()}
|
|
195
|
+
/>
|
|
196
|
+
</View>
|
|
197
|
+
</View>
|
|
198
|
+
:
|
|
199
|
+
<View style={{ flex:1 }}>
|
|
200
|
+
<View style={{ flex:1 }}>
|
|
201
|
+
<View style={{ borderRadius:8, padding:30 }}>
|
|
202
|
+
<View style={{ marginBottom:10 }}>
|
|
203
|
+
<Text size={18} color={Colors.brand.midnight} weight='bold'>MY {attribute.toUpperCase()}</Text>
|
|
204
|
+
</View>
|
|
205
|
+
<View style={{ flexDirection:'row', alignItems:'center', borderRadius:22, borderWidth:1, borderColor:Colors.shades.shade600 }}>
|
|
206
|
+
<View style={{ paddingLeft:10, paddingRight:15 }}>
|
|
207
|
+
{getAttributeIcon()}
|
|
208
|
+
</View>
|
|
209
|
+
<TextInput
|
|
210
|
+
value={value}
|
|
211
|
+
editable={false}
|
|
212
|
+
style={{ flex:1, backgroundColor:Colors.shades.shade100 }}
|
|
213
|
+
placeholderTextColor={Colors.brand.slate}
|
|
214
|
+
onChangeText={() => console.log('')}
|
|
215
|
+
/>
|
|
216
|
+
<View style={{ padding:10 }}>
|
|
217
|
+
<Icons.CheckCirlceIcon color={Colors.utility.success} size={14} />
|
|
218
|
+
</View>
|
|
219
|
+
</View>
|
|
220
|
+
</View>
|
|
221
|
+
<View style={{ borderRadius:8, padding:30, backgroundColor:Colors.shades.shade100 }}>
|
|
222
|
+
<View style={{ marginBottom:10 }}>
|
|
223
|
+
<Text size={18} color={Colors.brand.midnight} weight='bold'>ENTER {type.toUpperCase()}</Text>
|
|
224
|
+
{type == 'token' ?
|
|
225
|
+
<Text style={{ marginTop:5 }} size={14} color={Colors.brand.midnight} weight='regular'>We sent a one-time token to {value}. Please enter it below.</Text>
|
|
226
|
+
:
|
|
227
|
+
<Text style={{ marginTop:5 }} size={14} color={Colors.brand.midnight} weight='regular'>Please enter the password associated with the {attribute} {value}.</Text>
|
|
228
|
+
}
|
|
229
|
+
</View>
|
|
230
|
+
<View style={{ flexDirection:'row', alignItems:'center', borderRadius:22, borderWidth:1, borderColor:Colors.shades.shade600 }}>
|
|
231
|
+
<View style={{ paddingLeft:10, paddingRight:15 }}>
|
|
232
|
+
<Icons.LockClosedIcon
|
|
233
|
+
size={20}
|
|
234
|
+
color={Colors.brand.midnight}
|
|
235
|
+
/>
|
|
236
|
+
</View>
|
|
237
|
+
<TextInput
|
|
238
|
+
style={{ flex:1 }}
|
|
239
|
+
value={pass_token}
|
|
240
|
+
placeholder={`Enter ${type}`}
|
|
241
|
+
autoFocus={true}
|
|
242
|
+
secureTextEntry
|
|
243
|
+
textContentType={type=='password'?'password':'oneTimeCode'}
|
|
244
|
+
placeholderTextColor={Colors.brand.slate}
|
|
245
|
+
onChangeText={(text) => {
|
|
246
|
+
setLoginTry({
|
|
247
|
+
...login_try,
|
|
248
|
+
pass_token: text
|
|
249
|
+
})
|
|
250
|
+
}}
|
|
251
|
+
/>
|
|
252
|
+
<View style={{ padding:10 }}>
|
|
253
|
+
{ login_valid ?
|
|
254
|
+
<Icons.CheckCirlceIcon color={Colors.utility.success} size={14} />
|
|
255
|
+
:
|
|
256
|
+
<Icons.AlertIcon color={Colors.utility.warning} size={14} />
|
|
257
|
+
}
|
|
258
|
+
</View>
|
|
259
|
+
</View>
|
|
260
|
+
{login_try.error ?
|
|
261
|
+
<TouchableOpacity style={{ marginTop:10, padding:10, backgroundColor:Colors.shades.white, borderRadius:8 }} onPress={() => handleForgot()}>
|
|
262
|
+
<Text size={14} color={Colors.utility.error} weight='semibold' textAlign='center'>{login_try.error}</Text>
|
|
263
|
+
<Text style={{ marginTop:5 }} size={14} color={Colors.brand.electric} weight='bold' textAlign='center'>SEND ME A CODE INSTEAD</Text>
|
|
264
|
+
</TouchableOpacity>
|
|
265
|
+
:<></>}
|
|
266
|
+
</View>
|
|
267
|
+
</View>
|
|
268
|
+
<View style={{ padding:20, flexDirection:'row' }}>
|
|
269
|
+
<Button
|
|
270
|
+
title='BACK'
|
|
271
|
+
style={{ marginRight:5, flex:1 }}
|
|
272
|
+
title_color={Colors.brand.electric}
|
|
273
|
+
backgroundColor={Colors.shades.white}
|
|
274
|
+
borderWidth={1}
|
|
275
|
+
borderColor={Colors.brand.electric}
|
|
276
|
+
padding={15}
|
|
277
|
+
onPress={() => {
|
|
278
|
+
setLoginTry({ ...login_try, pass_token: '', visible:false });
|
|
279
|
+
}}
|
|
280
|
+
/>
|
|
281
|
+
<Button
|
|
282
|
+
title={halted?'Try again in 5 seconds':'LOGIN'}
|
|
283
|
+
style={{ flex:3, opacity:!login_valid||loading?0.5:1 }}
|
|
284
|
+
title_color={Colors.shades.white}
|
|
285
|
+
loading={login_try.loading}
|
|
286
|
+
backgroundColor={Colors.brand.electric}
|
|
287
|
+
disabled={!login_valid||loading}
|
|
288
|
+
padding={15}
|
|
289
|
+
onPress={() => handleLogin()}
|
|
290
|
+
/>
|
|
291
|
+
</View>
|
|
292
|
+
</View>
|
|
293
|
+
}
|
|
294
|
+
</View>
|
|
295
|
+
)
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
export default LoginForm
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React, { useEffect, useState } from 'react';
|
|
2
2
|
import { Button, Checkbox, Icons, Text, TextInput } from "../../Components";
|
|
3
3
|
import Colors from "../../constants/colors";
|
|
4
|
-
import type { AuthExecutionRequestProps, AuthStrategyIdentifierProps, AuthStrategyProps
|
|
4
|
+
import type { AuthExecutionRequestProps, AuthStrategyIdentifierProps, AuthStrategyProps } from '../api/types';
|
|
5
5
|
import { AuthenticateApi, AuthenticateHelpers } from '../api';
|
|
6
|
-
import {
|
|
6
|
+
import { Linking, TouchableOpacity, View , FlatList} from 'react-native';
|
|
7
7
|
|
|
8
8
|
type StrategyFormProps = {
|
|
9
9
|
visible:boolean,
|
|
@@ -14,10 +14,11 @@ type StrategyFormProps = {
|
|
|
14
14
|
source:string,
|
|
15
15
|
opt_in_url?:string,
|
|
16
16
|
referral_code?:string,
|
|
17
|
+
onLogin:() => void,
|
|
17
18
|
onAuthenticated: (access_token:string, refresh_token:string, expire_datetime:any) => void
|
|
18
19
|
}
|
|
19
20
|
|
|
20
|
-
const StrategyForm = ({ visible, auth_strategy_id,
|
|
21
|
+
const StrategyForm = ({ visible, auth_strategy_id, device_id, source, referral_code, width, opt_in_url, onAuthenticated, onLogin }:StrategyFormProps) => {
|
|
21
22
|
|
|
22
23
|
const [ action_loading, setActionLoading ] = useState(false);
|
|
23
24
|
const [ active_view, setActiveView ] = useState('authenticate');
|
|
@@ -26,7 +27,6 @@ const StrategyForm = ({ visible, auth_strategy_id, company_id, device_id, source
|
|
|
26
27
|
const [ verify_error, setVerifyError ] = useState<string|undefined>();
|
|
27
28
|
const [ verify_attempt_allowed, setVeryAttemptAllowed ] = useState(true);
|
|
28
29
|
const [ authenticated, setAuthenticated ] = useState(false);
|
|
29
|
-
console.log(authenticated)
|
|
30
30
|
const [ auth_execution_request, setAuthExecutionRequest ] = useState<AuthExecutionRequestProps>({
|
|
31
31
|
auth_strategy_id: auth_strategy_id,
|
|
32
32
|
device_id,
|
|
@@ -41,17 +41,15 @@ const StrategyForm = ({ visible, auth_strategy_id, company_id, device_id, source
|
|
|
41
41
|
} | undefined>(undefined)
|
|
42
42
|
const [ strategy, setStrategy ] = useState<{
|
|
43
43
|
loading:boolean,
|
|
44
|
-
company?:CompanyProps,
|
|
45
44
|
auth_strategy?:AuthStrategyProps,
|
|
46
45
|
auth_strategy_identifiers:AuthStrategyIdentifierProps[]
|
|
47
46
|
}>({
|
|
48
47
|
loading: false,
|
|
49
|
-
company:undefined,
|
|
50
48
|
auth_strategy:undefined,
|
|
51
49
|
auth_strategy_identifiers:[]
|
|
52
50
|
});
|
|
53
51
|
|
|
54
|
-
const {
|
|
52
|
+
const { auth_strategy, auth_strategy_identifiers } = strategy;
|
|
55
53
|
const verify_strategy_identifier = auth_strategy_identifiers.find(asi => asi.auth_strategy_identifier_id == verify_state?.auth_strategy_identifier_id);
|
|
56
54
|
|
|
57
55
|
useEffect(() => {
|
|
@@ -62,12 +60,7 @@ const StrategyForm = ({ visible, auth_strategy_id, company_id, device_id, source
|
|
|
62
60
|
const setUpWizard = async(auth_strategy_id:string) => {
|
|
63
61
|
setStrategy({ ...strategy, loading:true });
|
|
64
62
|
//Get auth strategy from server
|
|
65
|
-
const { auth_strategy, auth_strategy_identifiers } = await AuthenticateApi.getAuthStrategyById(auth_strategy_id);
|
|
66
|
-
let company:CompanyProps|undefined = undefined
|
|
67
|
-
if(company_id){
|
|
68
|
-
const company_resp = await AuthenticateApi.getCompanyById(company_id)
|
|
69
|
-
company = company_resp.company
|
|
70
|
-
}
|
|
63
|
+
const { auth_strategy, auth_strategy_identifiers } = await AuthenticateApi.getAuthStrategyById(auth_strategy_id);
|
|
71
64
|
let unique_attributes = auth_strategy_identifiers.map(asi => {
|
|
72
65
|
//if(!asi.auth_identifier){ return }
|
|
73
66
|
return { attribute: asi.auth_identifier?.attribute ?? '', value: '' }
|
|
@@ -84,34 +77,42 @@ const StrategyForm = ({ visible, auth_strategy_id, company_id, device_id, source
|
|
|
84
77
|
setStrategy({
|
|
85
78
|
...strategy,
|
|
86
79
|
auth_strategy,
|
|
87
|
-
company,
|
|
88
80
|
auth_strategy_identifiers,
|
|
89
81
|
loading:false
|
|
90
82
|
})
|
|
91
83
|
}
|
|
92
84
|
|
|
85
|
+
const getAttributeIcon = (attribute:string) => {
|
|
86
|
+
switch(attribute){
|
|
87
|
+
case 'email': return <Icons.EmailIcon size={20} color={Colors.brand.midnight}/>
|
|
88
|
+
case 'phone': return <Icons.PhoneIcon size={20} color={Colors.brand.midnight} />
|
|
89
|
+
case 'username': return <Icons.UserIcon size={20} color={Colors.brand.midnight} />
|
|
90
|
+
default: return <Icons.UserIcon size={20} color={Colors.brand.midnight} />
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
93
94
|
const verifyAuthStrategyIdentifier = async() => {
|
|
95
|
+
if(authenticated){ return }
|
|
94
96
|
if(!verify_state){ return }
|
|
95
97
|
if(action_loading){ return } //No mashy mashy
|
|
96
98
|
if(!verify_attempt_allowed){ return }
|
|
97
99
|
setVeryAttemptAllowed(false);
|
|
98
100
|
setActionLoading(true);
|
|
99
|
-
const { result, access_token, refresh_token, expire_datetime } = await AuthenticateApi.verifyAuthStrategyIdentifier(verify_state.auth_strategy_identifier_id, verify_state.verification_session_id, token, device_id);
|
|
101
|
+
const { result, access_token, refresh_token, expire_datetime } = await AuthenticateApi.verifyAuthStrategyIdentifier(verify_state.auth_strategy_identifier_id, verify_state.verification_session_id, token, device_id as string);
|
|
100
102
|
if(result == 'fail' || !access_token || !refresh_token){
|
|
101
103
|
setVerifyError(`Invalid code / password. Please try again after 10 seconds`)
|
|
102
104
|
setTimeout(() => {
|
|
103
105
|
setVeryAttemptAllowed(true);
|
|
104
106
|
setVerifyError(undefined)
|
|
107
|
+
setActionLoading(false);
|
|
105
108
|
}, 10000);
|
|
106
109
|
} else {
|
|
107
110
|
setAuthenticated(true);
|
|
108
111
|
setTimeout(() => {
|
|
109
112
|
onAuthenticated(access_token, refresh_token, expire_datetime);
|
|
113
|
+
setActionLoading(false);
|
|
110
114
|
}, 1500);
|
|
111
115
|
}
|
|
112
|
-
setActionLoading(false);
|
|
113
|
-
|
|
114
|
-
|
|
115
116
|
}
|
|
116
117
|
|
|
117
118
|
const executeAuthStrategy = async() => {
|
|
@@ -141,6 +142,9 @@ const StrategyForm = ({ visible, auth_strategy_id, company_id, device_id, source
|
|
|
141
142
|
<Text size={16} color={Colors.brand.midnight} weight='bold'>{data.item.label}</Text>
|
|
142
143
|
<Text style={{ marginTop:4 }} size={14} color={Colors.brand.midnight} weight='regular'>{data.item.description}</Text>
|
|
143
144
|
<View style={{ marginTop:5, flexDirection:'row', alignItems:'center', borderRadius:22, borderWidth:1, borderColor:Colors.shades.shade600 }}>
|
|
145
|
+
<View style={{ paddingLeft:10, paddingRight:15 }}>
|
|
146
|
+
{getAttributeIcon(data.item.auth_identifier.attribute)}
|
|
147
|
+
</View>
|
|
144
148
|
<TextInput
|
|
145
149
|
style={{ flex:1 }}
|
|
146
150
|
value={auth_request.pretty_value ?? auth_request.value}
|
|
@@ -182,25 +186,9 @@ const StrategyForm = ({ visible, auth_strategy_id, company_id, device_id, source
|
|
|
182
186
|
}
|
|
183
187
|
|
|
184
188
|
const strategy_valid = AuthenticateHelpers.isStrategyValid(auth_execution_request)
|
|
185
|
-
if(!visible){ return <></> }
|
|
189
|
+
if(!visible || strategy.loading){ return <></> }
|
|
186
190
|
return (
|
|
187
|
-
<View>
|
|
188
|
-
{company ?
|
|
189
|
-
<View style={{ padding:20, flexDirection:'row', alignItems:'center', borderTopRightRadius:22, borderTopLeftRadius:22, borderBottomWidth:1, borderColor:Colors.accents.accent200 }}>
|
|
190
|
-
<View style={{ flex:1, marginRight:10 }}>
|
|
191
|
-
<Text size={28} weight='bold' color={Colors.brand.midnight}>Welcome!</Text>
|
|
192
|
-
<Text style={{ marginTop:5 }} color={Colors.brand.midnight} size={14} weight='semibold' textAlign='left'>Continue to sign up with BettorEdge</Text>
|
|
193
|
-
</View>
|
|
194
|
-
<View>
|
|
195
|
-
<Image
|
|
196
|
-
source={{ uri: company?.company_image?.url }}
|
|
197
|
-
style={{ width: width * 0.15, height: width * 0.15, borderRadius:8 }}
|
|
198
|
-
resizeMode='cover'
|
|
199
|
-
/>
|
|
200
|
-
</View>
|
|
201
|
-
</View>
|
|
202
|
-
:<></>}
|
|
203
|
-
|
|
191
|
+
<View style={{ width:width, flex:1 }}>
|
|
204
192
|
{active_view == 'authenticate' ?
|
|
205
193
|
|
|
206
194
|
<View nativeID="sign_up" style={{ flex:1 }}>
|
|
@@ -221,13 +209,23 @@ const StrategyForm = ({ visible, auth_strategy_id, company_id, device_id, source
|
|
|
221
209
|
disabled={action_loading || !strategy_valid || !opted_in}
|
|
222
210
|
title_color={Colors.shades.white}
|
|
223
211
|
backgroundColor={Colors.brand.electric}
|
|
224
|
-
borderRadius={8}
|
|
212
|
+
//borderRadius={8}
|
|
225
213
|
padding={15}
|
|
226
214
|
onPress={() => {
|
|
227
215
|
executeAuthStrategy()
|
|
228
216
|
}}
|
|
229
217
|
/>
|
|
230
218
|
</View>
|
|
219
|
+
{auth_strategy?.allow_login ?
|
|
220
|
+
<View style={{ padding:10, backgroundColor:Colors.shades.shade100 }}>
|
|
221
|
+
<Button
|
|
222
|
+
title='Already Signed Up? Login Here'
|
|
223
|
+
title_color={Colors.brand.electric}
|
|
224
|
+
backgroundColor='transparent'
|
|
225
|
+
onPress={() => onLogin()}
|
|
226
|
+
/>
|
|
227
|
+
</View>
|
|
228
|
+
:<></>}
|
|
231
229
|
{active_view == 'authenticate' && opt_in_url ?
|
|
232
230
|
<View style={{ flexDirection:'row', alignItems:'center', padding:20 }}>
|
|
233
231
|
<Checkbox
|
|
@@ -251,7 +249,7 @@ const StrategyForm = ({ visible, auth_strategy_id, company_id, device_id, source
|
|
|
251
249
|
<Text size={18} color={Colors.brand.midnight} weight='semibold' textAlign="center">{verify_strategy_identifier.verify_label??'Enter Verification Code'}</Text>
|
|
252
250
|
<View style={{ padding:10 }}>
|
|
253
251
|
<TextInput
|
|
254
|
-
style={{ textAlign:'center', fontFamily:'barlow-bold', fontSize:14,
|
|
252
|
+
style={{ textAlign:'center', fontFamily:'barlow-bold', fontSize:14, borderWidth:1, borderColor:Colors.shades.shade600 }}
|
|
255
253
|
value={token}
|
|
256
254
|
keyboardType='default'
|
|
257
255
|
autoFocus
|
|
@@ -268,14 +266,30 @@ const StrategyForm = ({ visible, auth_strategy_id, company_id, device_id, source
|
|
|
268
266
|
:<></>}
|
|
269
267
|
</View>
|
|
270
268
|
<View nativeID="action_row" style={{ flexDirection:'row', padding:10, paddingLeft:20, paddingRight:20 }}>
|
|
269
|
+
<Button
|
|
270
|
+
title={'BACK'}
|
|
271
|
+
loading={action_loading}
|
|
272
|
+
style={{ flex:1, marginRight:5 }}
|
|
273
|
+
//disabled={!token || action_loading || !verify_attempt_allowed}
|
|
274
|
+
title_color={Colors.brand.electric}
|
|
275
|
+
borderColor={Colors.brand.electric}
|
|
276
|
+
borderWidth={1}
|
|
277
|
+
//backgroundColor={Colors.utility.success}
|
|
278
|
+
//borderRadius={8}
|
|
279
|
+
padding={15}
|
|
280
|
+
onPress={() => {
|
|
281
|
+
setActiveView('authenticate');
|
|
282
|
+
setVerifyState(undefined)
|
|
283
|
+
}}
|
|
284
|
+
/>
|
|
271
285
|
<Button
|
|
272
|
-
title={verify_attempt_allowed? 'Verify': 'Retry in 10 seconds'}
|
|
286
|
+
title={verify_attempt_allowed && !action_loading? 'Verify': 'Retry in 10 seconds'}
|
|
273
287
|
loading={action_loading}
|
|
274
288
|
style={{ flex:3, opacity:token&&verify_attempt_allowed?1:0.5 }}
|
|
275
289
|
disabled={!token || action_loading || !verify_attempt_allowed}
|
|
276
290
|
title_color={Colors.shades.white}
|
|
277
291
|
backgroundColor={Colors.utility.success}
|
|
278
|
-
borderRadius={8}
|
|
292
|
+
//borderRadius={8}
|
|
279
293
|
padding={15}
|
|
280
294
|
onPress={() => {
|
|
281
295
|
verifyAuthStrategyIdentifier()
|