mirror of
https://github.com/wassname/talk.git
synced 2026-07-18 12:40:13 +08:00
Review changes.
This commit is contained in:
@@ -73,8 +73,10 @@ app.use(session(session_opts));
|
||||
app.use(cookieParser());
|
||||
|
||||
app.use((err, req, res, next) => {
|
||||
res.locals._csrf = req.csrfToken();
|
||||
return next();
|
||||
if (req.method === 'POST') {
|
||||
res.locals._csrf = req.csrfToken();
|
||||
}
|
||||
next();
|
||||
});
|
||||
|
||||
//==============================================================================
|
||||
|
||||
@@ -9,7 +9,7 @@ export const userStatusUpdate = (status, userId, commentId) => {
|
||||
return (dispatch, getState) => {
|
||||
dispatch({type: actions.UPDATE_STATUS_REQUEST});
|
||||
const _csrf = getState().auth.get('_csrf');
|
||||
return coralApi(`/users/${userId}/status`, {method: 'POST', body: {status: status, comment_id: commentId}, _csrf: _csrf})
|
||||
return coralApi(`/users/${userId}/status`, {method: 'POST', body: {status: status, comment_id: commentId}, _csrf})
|
||||
.then(res => dispatch({type: actions.UPDATE_STATUS_SUCCESS, res}))
|
||||
.catch(error => dispatch({type: actions.UPDATE_STATUS_FAILURE, error}));
|
||||
};
|
||||
|
||||
@@ -26,7 +26,7 @@ const signInFailure = error => ({type: actions.FETCH_SIGNIN_FAILURE, error});
|
||||
export const fetchSignIn = (formData) => (dispatch, getState) => {
|
||||
dispatch(signInRequest());
|
||||
const _csrf = getState().auth.get('_csrf');
|
||||
coralApi('/auth/local', {method: 'POST', body: formData, _csrf: _csrf})
|
||||
coralApi('/auth/local', {method: 'POST', body: formData, _csrf})
|
||||
.then(({user}) => {
|
||||
const isAdmin = !!user.roles.filter(i => i === 'admin').length;
|
||||
dispatch(signInSuccess(user, isAdmin));
|
||||
@@ -77,7 +77,7 @@ export const fetchSignUp = formData => (dispatch, getState) => {
|
||||
dispatch(signUpRequest());
|
||||
|
||||
const _csrf = getState().auth.get('_csrf');
|
||||
coralApi('/users', {method: 'POST', body: formData, _csrf: _csrf})
|
||||
coralApi('/users', {method: 'POST', body: formData, _csrf})
|
||||
.then(({user}) => {
|
||||
dispatch(signUpSuccess(user));
|
||||
setTimeout(() =>{
|
||||
@@ -97,7 +97,7 @@ export const fetchForgotPassword = email => (dispatch, getState) => {
|
||||
dispatch(forgotPassowordRequest(email));
|
||||
|
||||
const _csrf = getState().auth.get('_csrf');
|
||||
coralApi('/users/request-password-reset', {method: 'POST', body: {email}, _csrf: _csrf})
|
||||
coralApi('/users/request-password-reset', {method: 'POST', body: {email}, _csrf})
|
||||
.then(() => dispatch(forgotPassowordSuccess()))
|
||||
.catch(error => dispatch(forgotPassowordFailure(error)));
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user