Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DCJ-89] B2C Auth base #2611

Closed
wants to merge 11 commits into from
Closed
48 changes: 0 additions & 48 deletions cypress/component/SignIn/google_is.spec.js

This file was deleted.

3 changes: 3 additions & 0 deletions cypress/component/TermsOfService/tos_acceptance.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import React from 'react';
import { mount } from 'cypress/react';
import TermsOfServiceAcceptance from '../../../src/pages/TermsOfServiceAcceptance';
import { OidcBroker } from '../../../src/libs/auth/oidcBroker';
import { ToS } from '../../../src/libs/ajax/ToS';
import {Storage} from '../../../src/libs/storage';
import {Navigation} from '../../../src/libs/utils';
Expand All @@ -17,6 +18,8 @@ describe('Terms of Service Acceptance Page', function () {
cy.viewport(600, 300);
cy.stub(ToS, 'getDUOSText').returns(text);
cy.stub(ToS, 'acceptToS').returns(true);
cy.stub(OidcBroker, 'signIn').returns({});
cy.stub(OidcBroker, 'signOut');
cy.stub(Storage, 'getCurrentUser').returns({});
cy.stub(Navigation, 'back').returns(true);
const setUserIsLoggedSpy = cy.spy(Storage, 'setUserIsLogged');
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/home.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ describe('Home', function() {
it('Home page loads correctly', function() {
cy.visit(Cypress.env('baseUrl'));
cy.contains('DUOS');
cy.contains('Sign-in/Register');
cy.contains('Sign in');
cy.contains('What is DUOS and how does it work?');
cy.contains('DUOS for DACs');
cy.contains('Institutional Oversight');
Expand Down
137 changes: 28 additions & 109 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"@babel/plugin-proposal-class-properties": "7.18.6",
"@babel/preset-react": "7.24.7",
"@types/dompurify": "3.0.5",
"@types/history": "5.0.0",
"@types/history": "4.7.11",
"@types/lodash": "4.17.5",
"@types/react": "18.3.3",
"@types/react-modal": "3.16.3",
Expand All @@ -79,7 +79,7 @@
"eslint-plugin-flowtype": "8.0.3",
"eslint-plugin-react": "7.34.3",
"google-auth-library": "9.11.0",
"history": "5.3.0",
"history": "4.10.1",
"html-webpack-plugin": "5.6.0",
"prop-types": "15.8.1",
"react-error-overlay": "6.0.11",
Expand Down
27 changes: 7 additions & 20 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ import loadingImage from './images/loading-indicator.svg';

import {SpinnerComponent as Spinner} from './components/SpinnerComponent';
import {StackdriverReporter} from './libs/stackdriverReporter';
import {Storage} from './libs/storage';

import Routes from './Routes';
import {GoogleIS} from './libs/googleIS';
import { Storage } from './libs/storage';

function App() {
const [isLoggedIn, setIsLoggedIn] = useState(false);
const [isLoggedIn, setIsLoggedIn] = useState(Storage.userIsLogged());
const [env, setEnv] = useState('');
let history = useHistory();
let location = useLocation();
const history = useHistory();
const location = useLocation();

const trackPageView = (location) => {
ReactGA.send({ hitType: 'pageview', page: location.pathname+location.search });
Expand Down Expand Up @@ -66,26 +66,13 @@ function App() {
setUserIsLogged();
});

const signOut = async () => {
const clientId = await Config.getGoogleClientId();
await GoogleIS.revokeAccessToken(clientId);
await Storage.setUserIsLogged(false);
await Storage.clearStorage();
await setIsLoggedIn(false);
};

const signIn = async () => {
await Storage.setUserIsLogged(true);
await setIsLoggedIn(true);
};

return (
<div className="body">
<div className="wrap">
<div className="main">
<DuosHeader onSignOut={signOut} />
<DuosHeader />
<Spinner name="mainSpinner" group="duos" loadingImage={loadingImage} />
<Routes onSignOut={signOut} onSignIn={signIn} isLogged={isLoggedIn} env={env} />
<Routes isLogged={isLoggedIn} env={env} />
</div>
</div>
<DuosFooter />
Expand Down
7 changes: 0 additions & 7 deletions src/Routes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import SigningOfficialDataSubmitters from './pages/signing_official_console/Sign
import Translator from './pages/Translator';
import NIHPilotInfo from './pages/NIHPilotInfo';
import Status from './pages/Status';
import BackgroundSignIn from './pages/BackgroundSignIn';
import ConsentTextGenerator from './pages/ConsentTextGenerator';
import AdminManageInstitutions from './pages/AdminManageInstitutions';
import AdminManageLC from './pages/AdminManageLC';
Expand Down Expand Up @@ -52,12 +51,6 @@ const Routes = (props) => (
<Route exact path="/home" render={(routeProps) => <Home {...routeProps} {...props} />} />
<Route exact path="/status" render={(routeProps) => <Status {...routeProps} {...props} />} />
<Route exact path="/liveness" component={HealthCheck} />
<Route exact path="/backgroundsignin" render={
(routeProps) =>
checkEnv(envGroups.NON_STAGING)
? <BackgroundSignIn {...routeProps} />
: <NotFound />
} />
<Route path="/nih_ic_webform" component={NIHICWebform} />
<Route path="/nih_pilot_info" component={NIHPilotInfo} />
<Route path="/privacy" component={PrivacyPolicy} />
Expand Down
12 changes: 12 additions & 0 deletions src/appLoader.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { BrowserRouter } from 'react-router-dom';
import App from './App';
import { createRoot } from 'react-dom/client';
import React from 'react';

const container = document.getElementById('root');
const root = createRoot(container!);
root.render(
<BrowserRouter>
<App />
</BrowserRouter>
);
Loading
Loading