Skip to content

Commit 7d52bff

Browse files
authored
Merge pull request #24 from oslabs-beta/denton/fixdev
fixed the dev branch issue of cookie.username
2 parents edeabd9 + 08fe651 commit 7d52bff

File tree

5 files changed

+17
-18
lines changed

5 files changed

+17
-18
lines changed

app/src/components/marketplace/MarketplaceCard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ const MarketplaceCard = ({proj} :{proj: Project}) => {
4949
};
5050
const handleClone = async () => { // creates a copy of the project
5151
const docId = proj._id;
52-
const response = await axios.get(`/cloneProject/${docId}`);
52+
const response = await axios.get(`/cloneProject/${docId}`, { params: { username: window.localStorage.getItem('username') } });//passing in username as a query param is query params
5353
const project = response.data.project;
5454
alert('Project cloned!');
5555
setAnchorEl(null);

app/src/components/right/LoginButton.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,8 @@ const { API_BASE_URL, API_BASE_URL2 } = config;
1010
export default function LoginButton() {
1111
const state = useSelector((store:RootState) => store.appState);
1212
const dispatch = useDispatch();
13-
// console.log('doc cookie 1', Cookies.get())
1413
const handleLogout = () => {
15-
// console.log('doc cookie 2', Cookies.get('ssid'))
16-
// // document.cookie = 'ssid' + '=; Max-Age=0';
17-
// console.log('doc cookie 3', Cookies.get())
18-
14+
1915
window.localStorage.clear();
2016

2117
if (state.isLoggedIn) {

server/controllers/cookieController.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const cookieController: CookieController = {
1212
return next();
1313
},
1414

15+
1516
};
1617

1718
export default cookieController;

server/controllers/marketplaceController.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ const marketplaceController: MarketplaceController = {
116116
cloneProject: async (req, res, next) => {
117117
// pulls cookies from request
118118
const userId = req.cookies.ssid;
119-
const username = req.cookies.username;
119+
const username = req.query.username;
120120
try { // trying to find project, update its userId and username to a new project, then save it
121121
const originalProject = await Projects.findOne({ _id: req.params.docId }).exec();
122122
const updatedProject = originalProject.toObject({ minimize: false }); // minimize false makes sure Mongoose / MongoDB does not remove nested properties with values of empty objects {}

server/server.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,19 @@ const passportSetup = require('./routers/passport-setup');
6767
const session = require('express-session');
6868
import authRoutes from './routers/auth';
6969

70-
app.use(
71-
session({
72-
secret: process.env.SESSION_SECRET,
73-
resave: false,
74-
saveUninitialized: true,
75-
cookie: { maxAge: 24 * 60 * 60 * 1000 }
76-
})
77-
);
78-
79-
app.use(passport.initialize());
80-
app.use(passport.session());
70+
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
71+
//I don't believe this portion of the code is being used. It just creates a session cookie, but majority of the controllers right now use mongodb as a sessionController, not passport.
72+
// app.use(
73+
// session({
74+
// secret: process.env.SESSION_SECRET,
75+
// resave: false,
76+
// saveUninitialized: true,
77+
// cookie: { maxAge: 24 * 60 * 60 * 1000 }
78+
// })
79+
// );
80+
// app.use(passport.initialize());
81+
// app.use(passport.session());
82+
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
8183

8284
// go to other files
8385
// 8080 only for the container

0 commit comments

Comments
 (0)