Skip to content

Commit d4f1893

Browse files
committed
Minor tweaks. Updated dependencies. Fixed 'cookie' version in lock file.
1 parent bbaa981 commit d4f1893

File tree

9 files changed

+1002
-1101
lines changed

9 files changed

+1002
-1101
lines changed

.ncurc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// This allows us to "lock" Chai into v4.
1+
// This allows us to "lock" packages into specific versions (mostly because of ES updates).
22

33
{
4-
"reject": ["chai", "eslint"]
4+
"reject": ["chai", "eslint", "scrypt-kdf"]
55
}

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
[![Bootstrap version](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fraw.githubusercontent.com%2Fneonexus%2Fsails-react-bootstrap-webpack%2Fv6.0.0%2Fpackage.json&query=%24.devDependencies.bootstrap&label=Bootstrap&logo=bootstrap&logoColor=white)](https://getbootstrap.com)
77
[![Webpack version](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fraw.githubusercontent.com%2Fneonexus%2Fsails-react-bootstrap-webpack%2Fv6.0.0%2Fpackage.json&query=%24.devDependencies.webpack&label=Webpack&logo=webpack)](https://webpack.js.org)
88

9+
Latest version only:
10+
[![FOSSA License Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fneonexus%2Fsails-react-bootstrap-webpack.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fneonexus%2Fsails-react-bootstrap-webpack?ref=badge_shield)
11+
[![FOSSA Security Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fneonexus%2Fsails-react-bootstrap-webpack.svg?type=shield&issueType=security)](https://app.fossa.com/projects/git%2Bgithub.com%2Fneonexus%2Fsails-react-bootstrap-webpack?ref=badge_shield&issueType=security)
12+
913
[//]: # ([![Codecov](https://img.shields.io/codecov/c/github/neonexus/sails-react-bootstrap-webpack?logo=codecov)](https://codecov.io/gh/neonexus/sails-react-bootstrap-webpack))
1014

1115
[//]: # ([![Discord Server](https://img.shields.io/badge/Discord_server-silver?logo=discord)](http://discord.gg/Y5K73E84Tc))

api/helpers/is-password-valid.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,15 @@ module.exports = {
5151
}
5252

5353
if (inputs.user) {
54-
if (inputs.user.email && inputs.password.indexOf(inputs.user.email) >= 0) {
54+
if (inputs.user.email && inputs.password.toLowerCase().indexOf(inputs.user.email.toLowerCase()) >= 0) {
5555
errors.push('Password can not contain your email address.');
5656
}
5757

58-
if (inputs.user.firstName && inputs.password.indexOf(inputs.user.firstName) >= 0) {
58+
if (inputs.user.firstName && inputs.password.toLowerCase().indexOf(inputs.user.firstName.toLowerCase()) >= 0) {
5959
errors.push('Password can not contain your first name.');
6060
}
6161

62-
if (inputs.user.lastName && inputs.password.indexOf(inputs.user.lastName) >= 0) {
62+
if (inputs.user.lastName && inputs.password.toLowerCase().indexOf(inputs.user.lastName.toLowerCase()) >= 0) {
6363
errors.push('Password can not contain your last name.');
6464
}
6565
}

api/models/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
# Models
22

3+
Models describe / control the structure of data required for the project.
4+
35
See: https://sailsjs.com/documentation/concepts/models-and-orm/models

api/policies/isLoggedIn.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
const moment = require('moment-timezone');
22

3+
// Standardize messages; not just for ease of change...
4+
const invalid = 'Invalid credentials.';
5+
const notLoggedIn = 'You are not logged in';
6+
37
module.exports = async function(req, res, next) {
48
const sessionId = req.signedCookies[sails.config.session.name] || null; // signed cookies: https://sailsjs.com/documentation/reference/request-req/req-signed-cookies
59

@@ -13,7 +17,7 @@ module.exports = async function(req, res, next) {
1317

1418
await sails.models.session.destroy({id: sessionId});
1519

16-
return res.forbidden('You are not logged in');
20+
return res.forbidden(notLoggedIn);
1721
}
1822

1923
// If the session was found...
@@ -45,15 +49,15 @@ module.exports = async function(req, res, next) {
4549
}
4650

4751
if (!token.includes(':')) {
48-
return res.forbidden('Invalid credentials.');
52+
return res.forbidden(invalid);
4953
}
5054

5155
token = token.split(':');
5256

5357
const foundToken = await sails.models.apitoken.findOne({id: token[0]}).decrypt().populate('user');
5458

5559
if (!foundToken || token[1] !== foundToken.token) {
56-
return res.forbidden('Invalid credentials.');
60+
return res.forbidden(invalid);
5761
}
5862

5963
if (foundToken) {
@@ -66,5 +70,5 @@ module.exports = async function(req, res, next) {
6670
}
6771
}
6872

69-
return res.forbidden('You are not logged in');
73+
return res.forbidden(notLoggedIn);
7074
};

package-lock.json

Lines changed: 911 additions & 1055 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sails-react-bootstrap-webpack",
3-
"version": "6.0.0-rc2",
3+
"version": "6.0.0",
44
"description": "A glass-box starter framework that grows with you. Built on proven and reliable tech like Sails, React, Bootstrap & Webpack.",
55
"keywords": [
66
"sails",
@@ -18,22 +18,21 @@
1818
"csrf": "3.1.0",
1919
"json-stringify-safe": "5.0.1",
2020
"lodash": "4.17.21",
21-
"moment-timezone": "0.5.45",
21+
"moment-timezone": "0.5.46",
2222
"otplib": "12.0.1",
2323
"qrcode": "1.5.4",
2424
"sails": "1.5.12",
2525
"sails-hook-orm": "4.0.3",
2626
"sails-hook-sockets": "3.0.1",
2727
"sails-mysql": "3.0.1",
2828
"scrypt-kdf": "2.0.1",
29-
"superagent": "10.1.0"
29+
"superagent": "10.1.1"
3030
},
3131
"devDependencies": {
32-
"@babel/core": "7.25.7",
33-
"@babel/eslint-parser": "7.25.7",
34-
"@babel/preset-env": "7.25.7",
35-
"@babel/preset-react": "7.25.7",
36-
"@ngrok/ngrok": "^1.4.1",
32+
"@babel/core": "7.26.0",
33+
"@babel/eslint-parser": "7.25.9",
34+
"@babel/preset-env": "7.26.0",
35+
"@babel/preset-react": "7.25.9",
3736
"@popperjs/core": "2.11.8",
3837
"babel-loader": "9.2.1",
3938
"bootstrap": "5.3.3",
@@ -43,31 +42,31 @@
4342
"chai-uuid": "1.0.6",
4443
"codecov": "3.8.3",
4544
"copy-webpack-plugin": "12.0.2",
46-
"core-js": "3.38.1",
45+
"core-js": "3.39.0",
4746
"css-loader": "7.1.2",
4847
"eslint": "8.56.0",
49-
"eslint-plugin-react": "7.37.1",
48+
"eslint-plugin-react": "7.37.2",
5049
"favicons": "7.2.0",
5150
"favicons-webpack-plugin": "6.0.1",
5251
"file-loader": "6.2.0",
5352
"fixted": "4.2.6",
54-
"html-webpack-plugin": "5.6.0",
55-
"mini-css-extract-plugin": "2.9.1",
56-
"mocha": "10.7.3",
53+
"html-webpack-plugin": "5.6.3",
54+
"mini-css-extract-plugin": "2.9.2",
55+
"mocha": "10.8.2",
5756
"npm-run-all": "4.1.5",
5857
"nyc": "17.1.0",
5958
"prompts": "2.4.2",
6059
"prop-types": "15.8.1",
6160
"react": "18.3.1",
6261
"react-bootstrap": "2.10.5",
6362
"react-dom": "18.3.1",
64-
"react-router-dom": "6.26.2",
63+
"react-router-dom": "6.27.0",
6564
"readline-sync": "1.4.10",
66-
"sass": "1.79.4",
67-
"sass-loader": "16.0.2",
65+
"sass": "1.80.6",
66+
"sass-loader": "16.0.3",
6867
"style-loader": "4.0.0",
6968
"supertest": "7.0.0",
70-
"webpack": "5.95.0",
69+
"webpack": "5.96.1",
7170
"webpack-cli": "5.1.4",
7271
"webpack-dev-server": "5.1.0",
7372
"webpack-merge": "6.0.1"

setup.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ if (fs.existsSync(configPath)) {
4040
const answer = await prompts({
4141
type: 'confirm',
4242
name: 'moveOn',
43-
message: 'A `local.js` config file already exists. Continuing will completely rewrite this file. Are you sure you want to continue?',
43+
message: 'A `local.js` config file already exists. Continuing will completely rewrite this file (using the values from this config file as defaults). Are you sure you want to continue?',
4444
initial: false
4545
});
4646

@@ -416,7 +416,7 @@ function generateDEK(){
416416

417417
function installNgrok() {
418418
return new Promise((resolve, reject) => {
419-
const ngrokInstall = spawn('npm', ['install', '@ngrok/ngrok@v0.9.1', '--save-dev', '--save-exact'], {cwd: __dirname, stdio: 'inherit'});
419+
const ngrokInstall = spawn('npm', ['install', '@ngrok/ngrok@v1.4.1', '--save-dev', '--save-exact'], {cwd: __dirname, stdio: 'inherit'});
420420

421421
ngrokInstall.on('error', (err) => {
422422
return reject(err);

test/unit/helpers/is-password-valid.test.js

Lines changed: 54 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -81,40 +81,76 @@ describe('isPasswordValid Helper', function() {
8181
lastName: 'McUser'
8282
};
8383

84-
it('should not allow email in password', async function() {
85-
const isValid = await sails.helpers.isPasswordValid.with({
86-
password: '0987' + user.email + '1234A',
84+
it('should not allow email in different cases in password', async function() {
85+
const tests = [];
86+
87+
tests[0] = await sails.helpers.isPasswordValid.with({
88+
password: '0987' + user.email.toUpperCase() + '1234a',
8789
user,
8890
skipPwned: true
8991
});
9092

91-
isValid.should.be.an('array');
92-
isValid.length.should.equal(1);
93-
isValid[0].should.equal('Password can not contain your email address.');
93+
tests[0].should.be.an('array');
94+
tests[0].length.should.equal(1);
95+
tests[0][0].should.equal('Password can not contain your email address.');
96+
97+
tests[1] = await sails.helpers.isPasswordValid.with({
98+
password: '0987' + user.email.toLowerCase() + '1234A',
99+
user,
100+
skipPwned: true
101+
});
102+
103+
tests[1].should.be.an('array');
104+
tests[1].length.should.equal(1);
105+
tests[1][0].should.equal('Password can not contain your email address.');
94106
});
95107

96-
it('should not allow first name in password', async function() {
97-
const isValid = await sails.helpers.isPasswordValid.with({
98-
password: 'I am the best Tester ever!',
108+
it('should not allow first name in different cases in password', async function() {
109+
const tests = [];
110+
111+
tests[0] = await sails.helpers.isPasswordValid.with({
112+
password: 'I am the best TESTER ever!', // Tester is the first name
113+
user,
114+
skipPwned: true
115+
});
116+
117+
tests[0].should.be.an('array');
118+
tests[0].length.should.equal(1);
119+
tests[0][0].should.equal('Password can not contain your first name.');
120+
121+
tests[1] = await sails.helpers.isPasswordValid.with({
122+
password: 'I am the best tester ever!', // Tester is the first name
99123
user,
100124
skipPwned: true
101125
});
102126

103-
isValid.should.be.an('array');
104-
isValid.length.should.equal(1);
105-
isValid[0].should.equal('Password can not contain your first name.');
127+
tests[1].should.be.an('array');
128+
tests[1].length.should.equal(1);
129+
tests[1][0].should.equal('Password can not contain your first name.');
106130
});
107131

108-
it('should not allow last name in password', async function() {
109-
const isValid = await sails.helpers.isPasswordValid.with({
110-
password: 'Hurray for the great, McUser!',
132+
it('should not allow last name in different cases in password', async function() {
133+
const tests = [];
134+
135+
tests[0] = await sails.helpers.isPasswordValid.with({
136+
password: 'Hurray for the great, mcuser!', // McUser is last name
137+
user,
138+
skipPwned: true
139+
});
140+
141+
tests[0].should.be.an('array');
142+
tests[0].length.should.equal(1);
143+
tests[0][0].should.equal('Password can not contain your last name.');
144+
145+
tests[1] = await sails.helpers.isPasswordValid.with({
146+
password: 'Hurray for the great, MCUSER!', // McUser is last name
111147
user,
112148
skipPwned: true
113149
});
114150

115-
isValid.should.be.an('array');
116-
isValid.length.should.equal(1);
117-
isValid[0].should.equal('Password can not contain your last name.');
151+
tests[1].should.be.an('array');
152+
tests[1].length.should.equal(1);
153+
tests[1][0].should.equal('Password can not contain your last name.');
118154
});
119155
});
120156

0 commit comments

Comments
 (0)