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

Add static 508 banner text for local dev builds and cleanup logging #355

Merged
merged 3 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions backend/src/api/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,6 @@ app.post('/auth/okta-callback', async (req, res) => {
const clientId = process.env.REACT_APP_COGNITO_CLIENT_ID;
const callbackUrl = process.env.REACT_APP_COGNITO_CALLBACK_URL;
const domain = process.env.REACT_APP_COGNITO_DOMAIN;
console.log('Okta ClientID: ', clientId);
console.log('Okta CallbackURL: ', callbackUrl);
console.log('Okta Domain: ', domain);

if (!code) {
return res.status(400).json({ message: 'Missing authorization code' });
Expand All @@ -202,7 +199,6 @@ app.post('/auth/okta-callback', async (req, res) => {
},
body: tokenData
});
console.log('Okta token response: ', response);
const { id_token, access_token, refresh_token } = await response.json();

if (!id_token) {
Expand All @@ -216,12 +212,6 @@ app.post('/auth/okta-callback', async (req, res) => {

const cognitoUsername = decodedToken['cognito:username'];
const oktaId = decodedToken['custom:OKTA_ID'];
console.log('Cognito Username:', cognitoUsername);
console.log('Cognito OKTA_ID:', oktaId);

console.log('ID Token:', id_token);
console.log('Decoded Token:', decodedToken);

jwt.verify(
id_token,
auth.getOktaKey,
Expand Down
1 change: 0 additions & 1 deletion backend/src/api/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ export const callback = async (event, context) => {
user.loginBlockedByMaintenance = loginBlocked;
user.save();
}
console.log(user);

// If user does not exist, create it
if (!user) {
Expand Down
1 change: 0 additions & 1 deletion backend/src/api/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,6 @@ export const sendRegistrationApprovedEmail = async (
*/
async function isMajorActiveMaintenance(): Promise<boolean> {
const now = new Date();
console.log(now);
try {
// DB connection
await connectToDatabase();
Expand Down
28 changes: 25 additions & 3 deletions backend/src/api/notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ import { validateBody, wrapHandler, NotFound, Unauthorized } from './helpers';
import { isGlobalWriteAdmin } from './auth';
import S3Client from '../tasks/s3-client';

// 508 Warning Banner S3 filename
const bannerFileName = '508warningtext.txt';

// Default 508 Warning Banner for local dev
const default508Banner =
'CISA is committed to providing access for all individuals with disabilities, \
including members of the public and all employees. While this website is not \
yet fully accessible to users with disabilities as required by Section \
[508](https://cisa.gov/accessibility) federal law, CISA is working diligently \
to resolve those issues. If you experience accessibility issues, please email \
[TOC@mail.cisa.dhs.gov](mailto:TOC@mail.cisa.dhs.gov) for assistance.';

class NewNotification {
@IsDateString()
startDatetime?: string;
Expand Down Expand Up @@ -99,8 +111,6 @@ export const list = wrapHandler(async (event) => {
}
});

console.log('Notification.find result: ', result);

return {
statusCode: 200,
body: JSON.stringify(result)
Expand Down Expand Up @@ -161,16 +171,28 @@ export const update = wrapHandler(async (event) => {
* - Notifications
*/
export const get508Banner = wrapHandler(async () => {
const bannerFileName = '508warningtext.txt';
// Return hardcoded banner for local builds
if (process.env.IS_LOCAL) {
console.log('Using default banner for 508 warning: ', default508Banner);
// API Response
return {
statusCode: 200,
body: JSON.stringify(default508Banner)
};
}

// Handle normal S3 logic
try {
const client = new S3Client();
const bannerResult = await client.getEmailAsset(bannerFileName);
// API Response
return {
statusCode: 200,
body: JSON.stringify(bannerResult)
};
} catch (error) {
console.log('S3 Banner Error: ', error);
// API Error Response
return {
statusCode: 500,
body: 'Error retrieving file from S3. See details in logs.'
Expand Down
Loading