-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from SailingSteve/steveStaffClientFeb3-3pm
First steps toward verify email address
- Loading branch information
Showing
30 changed files
with
349 additions
and
288 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,34 @@ | ||
import React from 'react'; | ||
import { Navigate, Outlet, useLocation } from 'react-router'; | ||
import webAppConfig from './config'; | ||
|
||
|
||
/* global $ */ | ||
|
||
// import React from 'react'; | ||
// import { Navigate, Outlet, useLocation } from 'react-router'; | ||
// import { useConnectAppContext } from './contexts/ConnectAppContext'; | ||
// | ||
// import webAppConfig from './config'; | ||
// | ||
// | ||
// /* global $ */ | ||
// | ||
// eslint-disable-next-line import/prefer-default-export | ||
export async function getAuthentication () { | ||
if (window.$) { | ||
console.log(`${webAppConfig.STAFF_API_SERVER_API_ROOT_URL}getAuth`); | ||
$.get(`${webAppConfig.STAFF_API_SERVER_API_ROOT_URL}auth/`, | ||
{}, | ||
(data, status) => { | ||
console.log(`/auth response -- status: '${status}', data: ${JSON.stringify(data)}`); | ||
localStorage.setItem('isAuthenticated', data.userId); | ||
return data.authenticated; | ||
}); | ||
} else { | ||
console.log('jquery not yet defined in getAuthentication'); | ||
} | ||
} | ||
// export async function getAuthentication () { | ||
// if (window.$) { | ||
// console.log(`${webAppConfig.STAFF_API_SERVER_API_ROOT_URL}getAuth`); | ||
// $.get(`${webAppConfig.STAFF_API_SERVER_API_ROOT_URL}auth/`, | ||
// {}, | ||
// (data, status) => { | ||
// console.log(`/auth response -- status: '${status}', data: ${JSON.stringify(data)}`); | ||
// localStorage.setItem('isAuthenticated', data.userId); | ||
// return data.authenticated; | ||
// }); | ||
// } else { | ||
// console.log('jquery not yet defined in getAuthentication'); | ||
// } | ||
// } | ||
|
||
// Routes in App.jsx wrapped with PrivateRoute require authentication to access | ||
export const PrivateRoute = () => { | ||
console.log('========= PrivateRoute =========== isAuth: ', localStorage.getItem('isAuthenticated')); | ||
const location = useLocation(); | ||
const isAuthenticated = localStorage.getItem('isAuthenticated'); | ||
return isAuthenticated ? <Outlet /> : <Navigate to="/login" state={{ from: location }} replace />; | ||
}; | ||
// eslint-disable-next-line import/prefer-default-export | ||
// export const PrivateRoute = () => { | ||
// const { getAppContextValue } = useConnectAppContext(); | ||
// console.log('========= PrivateRoute =========== isAuth: ', localStorage.getItem('isAuthenticated')); | ||
// const location = useLocation(); | ||
// const isAuthenticated = getAppContextValue('isAuthenticated'); | ||
// return isAuthenticated ? <Outlet /> : <Navigate to="/login" state={{ from: location }} replace />; | ||
// }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import React from 'react'; | ||
import { Navigate, Outlet, useLocation } from 'react-router'; | ||
import { authLog } from '../common/utils/logging'; | ||
import { useConnectAppContext } from '../contexts/ConnectAppContext'; | ||
|
||
const PrivateRoute = () => { | ||
const { getAppContextValue } = useConnectAppContext(); | ||
const isAuthenticated = getAppContextValue('isAuthenticated'); | ||
authLog('========= PrivateRoute =========== isAuthenticated: ', isAuthenticated); | ||
const location = useLocation(); | ||
|
||
return isAuthenticated ? <Outlet /> : <Navigate to="/login" state={{ from: location }} replace />; | ||
}; | ||
|
||
export default PrivateRoute; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.