warn user of session change when deleting a project or saving a new project
This commit is contained in:
parent
65592cbf9e
commit
1a22998ff8
3 changed files with 26 additions and 5 deletions
|
@ -107,10 +107,16 @@ export function saveProject(autosave = false) {
|
|||
}
|
||||
}
|
||||
})
|
||||
.catch(response => dispatch({
|
||||
type: ActionTypes.PROJECT_SAVE_FAIL,
|
||||
error: response.data
|
||||
}));
|
||||
.catch(response => {
|
||||
if (response.status === 403) {
|
||||
dispatch(showAuthenticationError());
|
||||
} else {
|
||||
dispatch({
|
||||
type: ActionTypes.PROJECT_SAVE_FAIL,
|
||||
error: response.data
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import * as ActionTypes from '../../../constants';
|
||||
import axios from 'axios';
|
||||
import { showAuthenticationError } from './ide';
|
||||
|
||||
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,
|
||||
id
|
||||
});
|
||||
})
|
||||
.catch(response => {
|
||||
if (response.status === 403) {
|
||||
dispatch(showAuthenticationError());
|
||||
} else {
|
||||
dispatch({
|
||||
type: ActionTypes.ERROR,
|
||||
error: response.data
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
|
|
@ -5,8 +5,12 @@ import request from 'request';
|
|||
|
||||
|
||||
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 = {
|
||||
user: req.user ? req.user._id : undefined // eslint-disable-line no-underscore-dangle
|
||||
user: req.user._id
|
||||
};
|
||||
|
||||
projectValues = Object.assign(projectValues, req.body);
|
||||
|
|
Loading…
Reference in a new issue