From 8dd239ebe5ab40d3df596937710f9e215a54e062 Mon Sep 17 00:00:00 2001 From: Ben Wheeler Date: Fri, 7 Dec 2018 11:00:43 -0500 Subject: [PATCH] use authorUsername, not users own username, in hitting logProjectView endpoint; use cookie and tokens in request --- src/redux/preview.js | 9 ++++++--- src/views/preview/project-view.jsx | 6 +++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/redux/preview.js b/src/redux/preview.js index 08f56ec73..475e018f5 100644 --- a/src/redux/preview.js +++ b/src/redux/preview.js @@ -885,11 +885,14 @@ module.exports.updateProjectThumbnail = (id, blob) => (dispatch => { }); }); -module.exports.logProjectView = (id, username) => (dispatch => { +module.exports.logProjectView = (id, authorUsername, token) => (dispatch => { dispatch(module.exports.setFetchStatus('project-log-view', module.exports.Status.FETCHING)); api({ - uri: `/users/${username}/projects/${id}/views`, - method: 'POST' + uri: `/users/${authorUsername}/projects/${id}/views`, + method: 'POST', + authentication: token, + withCredentials: true, + useCsrf: true }, (err, body, res) => { if (err || res.statusCode !== 200) { dispatch(module.exports.setFetchStatus('project-log-view', module.exports.Status.ERROR)); diff --git a/src/views/preview/project-view.jsx b/src/views/preview/project-view.jsx index d76f0dc5f..f9f9e9856 100644 --- a/src/views/preview/project-view.jsx +++ b/src/views/preview/project-view.jsx @@ -343,7 +343,7 @@ class Preview extends React.Component { this.props.reportProject(this.state.projectId, formData, this.props.user.token); } handleGreenFlag () { - this.props.logProjectView(this.props.projectInfo.id, this.props.user.username); + this.props.logProjectView(this.props.projectInfo.id, this.props.authorUsername, this.props.user.token); } handlePopState () { const path = window.location.pathname.toLowerCase(); @@ -890,8 +890,8 @@ const mapDispatchToProps = dispatch => ({ getLovedStatus: (id, username, token) => { dispatch(previewActions.getLovedStatus(id, username, token)); }, - logProjectView: (id, username) => { - dispatch(previewActions.logProjectView(id, username)); + logProjectView: (id, authorUsername, token) => { + dispatch(previewActions.logProjectView(id, authorUsername, token)); }, setLovedStatus: (loved, id, username, token) => { dispatch(previewActions.setLovedStatus(loved, id, username, token));