Skip to content

Commit f0cfe17

Browse files
committed
fixed save project
Co-authored-by: Sophia Bui <[email protected]> Co-authored-by: rachelk585 <[email protected]> Co-authored-by: Adam Vanek <[email protected]>
1 parent 6ba8652 commit f0cfe17

File tree

3 files changed

+19
-19
lines changed

3 files changed

+19
-19
lines changed

config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ const config = {
44
DEV_PORT: 5656,
55
API_BASE_URL: isProduction
66
? 'http://reactypev15-env.eba-mbvivk7k.us-east-1.elasticbeanstalk.com'
7-
: 'http://localhost:5656',
7+
: 'http://localhost:8080',
88
API_BASE_URL2: isProduction
99
? 'http://reactypev15-env.eba-mbvivk7k.us-east-1.elasticbeanstalk.com'
10-
: 'http://localhost:8080'
10+
: 'http://localhost:8080',
1111
};
1212

1313
module.exports = config;

server/controllers/projectController.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const projectController: ProjectController = {
88
// saveProject saves current workspace to database
99
saveProject: (req, res, next) => {
1010
// pull project name and project itself from body
11+
console.log('req body', req.body)
1112
const { name, project, userId, username, comments } = req.body;
1213
// create createdBy field for the document
1314
const createdAt = Date.now();

server/controllers/sessionController.ts

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,31 @@ import { SessionController, SessionCookie } from '../interfaces';
66
dotenv.config();
77

88
const sessionController: SessionController = {
9-
// isLoggedIn finds the right session, if the session is invalid in the database, the app redirect user straight to the root endpoint witht he login page, if not, continue session
10-
isLoggedIn: (req, res, next) => {
9+
isLoggedIn: async (req, res, next) => {
10+
try {
1111
let cookieId;
12-
if (req.cookies.ssid) {
12+
if (req.cookies) {
1313
cookieId = req.cookies.ssid;
1414
} else {
1515
cookieId = req.body.userId;
1616
}
1717

1818
// find session from request session ID in mongodb
19-
Sessions.findOne({ cookieId }, (err, session) => {
20-
if (err) {
21-
return next({
22-
log: `Error in sessionController.isLoggedIn: ${err}`,
23-
message: {
24-
err: 'Error in sessionController.isLoggedIn, check server logs for details'
25-
}
26-
});
27-
}
28-
if (!session) {
29-
return res.redirect('/');
19+
const session = await Sessions.findOne({ cookieId });
20+
21+
if (!session) {
22+
return res.redirect('/');
23+
}
24+
return next();
25+
} catch (err) {
26+
return next({
27+
log: `Error in sessionController.isLoggedIn: ${err}`,
28+
message: {
29+
err: 'Error in sessionController.isLoggedIn, check server logs for details'
3030
}
31-
return next();
3231
});
33-
},
34-
32+
}
33+
},
3534
// startSession - create and save a new session into the database
3635
startSession: (req, res, next) => {
3736
// first check if user is logged in already

0 commit comments

Comments
 (0)