Skip to content

Commit 3cebe1e

Browse files
committed
Fixed webpack config. Made isLoggedIn policy clear cookie if not logged in.
1 parent 8849b8d commit 3cebe1e

File tree

5 files changed

+14
-12
lines changed

5 files changed

+14
-12
lines changed

api/policies/isLoggedIn.js

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ module.exports = async function(req, res, next) {
1717
return next();
1818
}
1919
}
20+
21+
res.clearCookie(sails.config.session.name, {signed: true, httpOnly: true, secure: sails.config.session.cookie.secure});
2022
}
2123

2224
return res.forbidden('You are not logged in');

assets/src/data/api.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -52,39 +52,39 @@ class api {
5252
req = {url: req};
5353
}
5454

55-
const thisReq = api.__buildRequestObj(requester.get(this.baseUrl + req.url), req);
55+
const thisReq = api.__buildRequestObj(requester.get(this.baseUrl + req.url).withCredentials(), req);
5656

57-
thisReq.then((res) => api.__buildResponseWrapper(res, good), (err) => bad(err, err.response.body));
57+
return thisReq.then((res) => api.__buildResponseWrapper(res, good), (err) => bad(err, err.response.body));
5858
}
5959

6060
post(req, good, bad) {
6161
if (typeof req === 'string') {
6262
req = {url: req};
6363
}
6464

65-
const thisReq = api.__buildRequestObj(requester.post(this.baseUrl + req.url), req);
65+
const thisReq = api.__buildRequestObj(requester.post(this.baseUrl + req.url).withCredentials(), req);
6666

67-
thisReq.then((res) => api.__buildResponseWrapper(res, good), (err) => bad(err, err.response.body));
67+
return thisReq.then((res) => api.__buildResponseWrapper(res, good), (err) => bad(err, err.response.body));
6868
}
6969

7070
put(req, good, bad) {
7171
if (typeof req === 'string') {
7272
req = {url: req};
7373
}
7474

75-
const thisReq = api.__buildRequestObj(requester.put(this.baseUrl + req.url), req);
75+
const thisReq = api.__buildRequestObj(requester.put(this.baseUrl + req.url).withCredentials(), req);
7676

77-
thisReq.then((res) => api.__buildResponseWrapper(res, good), (err) => bad(err, err.response.body));
77+
return thisReq.then((res) => api.__buildResponseWrapper(res, good), (err) => bad(err, err.response.body));
7878
}
7979

8080
del(req, good, bad) {
8181
if (typeof req === 'string') {
8282
req = {url: req};
8383
}
8484

85-
const thisReq = api.__buildRequestObj(requester.del(this.baseUrl + req.url), req);
85+
const thisReq = api.__buildRequestObj(requester.del(this.baseUrl + req.url).withCredentials(), req);
8686

87-
thisReq.then((res) => api.__buildResponseWrapper(res, good), (err) => bad(err, err.response.body));
87+
return thisReq.then((res) => api.__buildResponseWrapper(res, good), (err) => bad(err, err.response.body));
8888
}
8989
}
9090

package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sails-react-bootstrap-webpack",
3-
"version": "1.5.1",
3+
"version": "1.5.2",
44
"description": "An opinionated base configuration of Sails, with Webpack for React support, and Bootstrap for styling.",
55
"keywords": [
66
"sails",

webpack/common.config.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ try {
1818
config = require(configPath);
1919
} else {
2020
configPath = (process.env.NODE_ENV !== 'production')
21-
? path.resolve(__dirname, '../env/development.js')
22-
: path.resolve(__dirname, '../env/production.js');
21+
? path.resolve(__dirname, '../config/env/development.js')
22+
: path.resolve(__dirname, '../config/env/production.js');
2323

2424
config = require(configPath);
2525
}

0 commit comments

Comments
 (0)