Skip to content

Commit 7440cdc

Browse files
committed
Merge branch 'master' of https://github.com/CodeForPhilly/paws-data-pipeline into refactor-360-ui
� Conflicts: � src/client/src/App.js
2 parents 9d75e52 + dca3811 commit 7440cdc

File tree

2 files changed

+60
-42
lines changed

2 files changed

+60
-42
lines changed

src/client/src/App.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import useToken from './components/Login/useToken';
1515
var jwt = require('jsonwebtoken');
1616

1717

18-
// Triggers token expiration check
18+
// Triggers token expiration check
1919
const sleep = time => new Promise(resolve => setTimeout(resolve, time))
2020
const expTimer = () => sleep(500).then(() => ({}))
2121

@@ -73,7 +73,7 @@ function AuthenticatedApp() {
7373

7474

7575
var decoded = jwt.decode(access_token, { complete: true });
76-
const userName = decoded?.payload.sub;
76+
7777
const userRole = decoded?.payload.role;
7878
var expTime = decoded?.payload.exp - Date.now()/1000;
7979

@@ -131,12 +131,12 @@ function AuthenticatedApp() {
131131

132132
function Home() {
133133
const {user} = useAuthState()
134+
/*eslint no-unused-vars: ["warn", { "varsIgnorePattern": "access_token" }]*/
134135
const { access_token, setToken } = useToken();
135136
return user ? <AuthenticatedApp /> : <Login setToken={setToken} />
136137
}
137138

138139
function App() {
139-
const { access_token, setToken } = useToken();
140140

141141
return (
142142
<AuthProvider>

src/client/src/pages/Check/Check.js

Lines changed: 57 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -16,44 +16,7 @@ export default function Check() {
1616

1717
let history = useHistory()
1818

19-
function authCheck() {
20-
// console.log('authCheck startfetch @ ' + DateTime.local().toFormat('HH:mm:ss.SSS'))
21-
fetch('http://localhost:5000/api/user/test_auth',
22-
{
23-
method: 'GET',
24-
headers: {
25-
'Content-Type': 'application/json',
26-
'Authorization': 'Bearer ' + access_token
27-
}
28-
})
29-
30-
.then((response) => {
31-
// console.log('authCheck handle response @ ' + DateTime.local().toFormat('HH:mm:ss.SSS'))
32-
if (!response.ok) {
33-
//throw (String(response.status + ':' + response.statusText))
34-
throw (response)
35-
}
36-
return response.json()
37-
} )
38-
.then((data) => {
39-
// console.log('authCheck data @ ' + DateTime.local().toFormat('HH:mm:ss.SSS'))
40-
setProcessStatus('complete');
41-
setData(data);
42-
})
43-
.catch((e) => {
44-
let errCode = e.status
45-
let errText = e.statusText
46-
47-
setToken(null) // Clear the token to force login again
48-
let errStr = String(e)
49-
setProcessStatus('error');
50-
setError(errStr);
51-
console.log(errCode + ':' + errText)
52-
history.push('/')
53-
return e
54-
});
55-
56-
} //
19+
5720

5821

5922

@@ -68,6 +31,59 @@ export default function Check() {
6831

6932
React.useEffect(() => {
7033

34+
35+
36+
function authCheck() {
37+
// console.log('authCheck startfetch @ ' + DateTime.local().toFormat('HH:mm:ss.SSS'))
38+
fetch('http://localhost:5000/api/user/test_auth',
39+
{
40+
method: 'GET',
41+
headers: {
42+
'Content-Type': 'application/json',
43+
'Authorization': 'Bearer ' + access_token
44+
}
45+
})
46+
47+
.then((response) => {
48+
// console.log('authCheck handle response @ ' + DateTime.local().toFormat('HH:mm:ss.SSS'))
49+
if (!response.ok) {
50+
//throw (String(response.status + ':' + response.statusText))
51+
throw (response)
52+
}
53+
return response.json()
54+
} )
55+
.then((data) => {
56+
// console.log('authCheck data @ ' + DateTime.local().toFormat('HH:mm:ss.SSS'))
57+
setProcessStatus('complete');
58+
setData(data);
59+
})
60+
.catch((e) => {
61+
let errCode = e.status
62+
let errText = e.statusText
63+
64+
setToken(null) // Clear the token to force login again
65+
let errStr = String(e)
66+
setProcessStatus('error');
67+
setError(errStr);
68+
console.log(errCode + ':' + errText)
69+
history.push('/')
70+
return e
71+
});
72+
73+
} //
74+
75+
76+
77+
78+
79+
80+
81+
82+
83+
84+
85+
86+
7187
if (! access_token){
7288
console.log("In Check w/o a token")
7389
}
@@ -77,7 +93,9 @@ export default function Check() {
7793
// console.log('After authCheck @ ' + DateTime.local().toFormat('HH:mm:ss.SSS'))
7894

7995

80-
}, [ processStatus, access_token]);
96+
},
97+
// eslint-disable-next-line
98+
[ processStatus, access_token, history ]);
8199

82100
// if (processStatus === 'loading') {
83101
// console.log('Check: if pc=l loading...')

0 commit comments

Comments
 (0)