warn user of session change when deleting a project or saving a new project

This commit is contained in:
Cassie Tarakajian 2017-01-13 17:32:06 -05:00
parent 65592cbf9e
commit 1a22998ff8
3 changed files with 26 additions and 5 deletions

View file

@ -107,10 +107,16 @@ export function saveProject(autosave = false) {
} }
} }
}) })
.catch(response => dispatch({ .catch(response => {
type: ActionTypes.PROJECT_SAVE_FAIL, if (response.status === 403) {
error: response.data dispatch(showAuthenticationError());
})); } else {
dispatch({
type: ActionTypes.PROJECT_SAVE_FAIL,
error: response.data
});
}
});
} }
}; };
} }

View file

@ -1,5 +1,6 @@
import * as ActionTypes from '../../../constants'; import * as ActionTypes from '../../../constants';
import axios from 'axios'; import axios from 'axios';
import { showAuthenticationError } from './ide';
const ROOT_URL = location.href.indexOf('localhost') > 0 ? 'http://localhost:8000/api' : '/api'; const ROOT_URL = location.href.indexOf('localhost') > 0 ? 'http://localhost:8000/api' : '/api';
@ -33,6 +34,16 @@ export function deleteProject(id) {
type: ActionTypes.DELETE_PROJECT, type: ActionTypes.DELETE_PROJECT,
id id
}); });
})
.catch(response => {
if (response.status === 403) {
dispatch(showAuthenticationError());
} else {
dispatch({
type: ActionTypes.ERROR,
error: response.data
});
}
}); });
}; };
} }

View file

@ -5,8 +5,12 @@ import request from 'request';
export function createProject(req, res) { export function createProject(req, res) {
if (!req.user) {
return res.status(403).send({ success: false, message: 'Session does not match owner of project.'});
}
let projectValues = { let projectValues = {
user: req.user ? req.user._id : undefined // eslint-disable-line no-underscore-dangle user: req.user._id
}; };
projectValues = Object.assign(projectValues, req.body); projectValues = Object.assign(projectValues, req.body);