Skip to content

Commit bf2c560

Browse files
committed
Minor tweaks.
1 parent d25fd17 commit bf2c560

File tree

12 files changed

+43
-435
lines changed

12 files changed

+43
-435
lines changed

CHANGELOG.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# Changelog
22

3-
## [v5.1.0](https://github.com/neonexus/sails-react-bootstrap-webpack/compare/v5.0.0...v5.1.0) (2023-12-22)
3+
## [v5.1.0](https://github.com/neonexus/sails-react-bootstrap-webpack/compare/v5.0.0...v5.1.0) (2024-01-06)
44
### Features
55

6-
* Minor tweaks / fixes.
7-
* Created the datastore wipe script, to reset LOCAL / DEVELOPMENT datastore. Will **not** run on PRODUCTION (or when migrate = "safe").
6+
* Created the datastore wipe script, to clear LOCAL / DEVELOPMENT datastore(s). It's just like `DROP`ing the database. Will **not** run on PRODUCTION (or when `migrate = 'safe'`).
87
* Converted `.mocharc.yml` -> `.mocharc` (JSON) to be more consistent.
98
* Made the Ngrok script capable of installing [`@ngrok/ngrok`](https://npmjs.com/package/@ngrok/ngrok) when needed.
109
* Minor visual fix in security settings page.
1110
* Built the "reactivate user" endpoint.
1211
* Corrected "edit" and "delete" user routes to use ID in the route.
12+
* Fixed issue in 2FA backup token generation, where it was possible to generate a pure number backup token. Now will ALWAYS have at least 1 letter.
1313
* Updated dependencies.
1414

1515
## [v5.0.0](https://github.com/neonexus/sails-react-bootstrap-webpack/compare/v4.3.1...v5.0.0) (2023-12-05)

README.md

+12-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,17 @@
99

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

12-
Kick-start your project with this startup in a box.
12+
This is a starter application, built on [Sails v1](https://sailsjs.com), [React](https://react.dev), [Bootstrap](https://getbootstrap.com), and [Webpack](https://webpack.js.org). It is designed
13+
so that multiple front-ends (a customer front-end, and an admin panel perhaps; more if need be) can live side-by-side, and use the same API. It even has built-in [Ngrok support](#working-with-ngrok).
14+
A virtual start-up in a box!
15+
16+
## Quick Install
17+
18+
```shell
19+
npx drfg neonexus/sails-react-bootstrap-webpack my-new-site
20+
npm run setup
21+
npm run start OR npm run ngrok
22+
```
1323

1424
## Table of Contents
1525

@@ -53,7 +63,7 @@ Kick-start your project with this startup in a box.
5363
* Automatic (incoming) request logging (manual outgoing), via Sails models / hooks.
5464
* Setup for Webpack auto-reload dev server. Build; save; auto-reload.
5565
* Setup so Sails will serve Webpack-built bundles as separate apps (so, a marketing site, and an admin site can live side-by-side).
56-
* More than a few custom [helper functions](api/helpers) to make life a little easier.
66+
* More than a few custom [API helper functions](api/helpers) to make life a little easier.
5767
* Includes [react-bootstrap](https://www.npmjs.com/package/react-bootstrap) to make using Bootstrap styles / features with React easier.
5868
* Schema validation and enforcement for `PRODUCTION`. See [schema validation and enforcement](#schema-validation-and-enforcement).
5969
* New passwords will be checked against the [PwnedPasswords API](https://haveibeenpwned.com/API/v3#PwnedPasswords). If there is a single hit for the password, an error will be given, and the user will

api/controllers/admin/create-user.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ module.exports = {
2525
type: 'string',
2626
isEmail: true,
2727
required: true,
28-
maxLength: 191
28+
maxLength: 191 // Max size of an utf8mb4 varchar in MySQL.
2929
},
3030

3131
role: {
@@ -69,7 +69,7 @@ module.exports = {
6969
isPasswordValid = true;
7070
password = sails.helpers.generateToken().substring(0, 42);
7171

72-
// should probably send password somehow; it will be scrubbed in the custom response (would be hashed anyway...)
72+
// should probably send password somehow; it will be scrubbed in the response (would be hashed anyway...)
7373
}
7474

7575
if (isPasswordValid !== true) {
@@ -99,7 +99,7 @@ module.exports = {
9999
}
100100

101101
/**
102-
* TODO: We should probably email the new user their new account info here if the password was generated (!inputs.setPassword)...
102+
* TODO: We should probably email the new user their new account info here if the password was generated (inputs.generatePassword)...
103103
*/
104104

105105
return exits.created({user});

api/helpers/generate-backup-tokens.js

+12-2
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,21 @@ module.exports = {
1414
exits: {},
1515

1616
fn: (inputs, exits) => {
17-
const token = sails.helpers.generateToken();
17+
let token = sails.helpers.generateToken();
1818
let backupTokens = [];
1919

20+
let last = null;
2021
for (let i = 0; i < 10; ++i) {
21-
backupTokens[i] = token.substring(i * 8, (i * 8) + 8);
22+
do {
23+
// Regenerate the token if this is our second time around in the do...while loop.
24+
if (last === i) {
25+
token = sails.helpers.generateToken();
26+
} else {
27+
last = i;
28+
}
29+
30+
backupTokens[i] = token.substring(i * 8, (i * 8) + 8);
31+
} while (!isNaN(backupTokens[i])); // Don't let pure number tokens through. They MUST have at least 1 letter.
2232
}
2333

2434
return exits.success(backupTokens);

api/models/Log.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ module.exports = {
2020

2121
description: {
2222
type: 'string',
23-
columnType: 'varchar(191)' // 191 is the max length to safely use the utf8mb4 charset
23+
columnType: 'varchar(191)' // 191 is the max length to safely use the utf8mb4 varchar.
2424
},
2525

2626
data: {

api/models/OTP.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ module.exports = {
2121

2222
secret: {
2323
type: 'string',
24-
columnType: 'varchar(191)',
24+
columnType: 'varchar(191)', // 191 is the max length to safely use the utf8mb4 varchar.
2525
encrypt: true,
2626
required: true
2727
},

api/models/RequestLog.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ module.exports = {
3434
host: {
3535
type: 'string',
3636
required: true,
37-
columnType: 'varchar(191)'
37+
columnType: 'varchar(191)' // 191 is the max length to safely use the utf8mb4 varchar.
3838
},
3939

4040
path: {
4141
type: 'string',
4242
required: true,
43-
columnType: 'varchar(191)'
43+
columnType: 'varchar(191)' // 191 is the max length to safely use the utf8mb4 varchar.
4444
},
4545

4646
headers: {

api/models/User.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ module.exports = {
5353
isEmail: true,
5454
required: true,
5555
// unique: true, // can NOT be unique, if we are using soft-deleted users; controller must deal with uniqueness
56-
columnType: 'varchar(191)'
56+
columnType: 'varchar(191)' // 191 is the max length to safely use the utf8mb4 varchar.
5757
},
5858

5959
firstName: {
@@ -71,7 +71,7 @@ module.exports = {
7171
password: {
7272
type: 'string',
7373
allowNull: true,
74-
columnType: 'varchar(191)',
74+
columnType: 'varchar(191)', // 191 is the max length to safely use the utf8mb4 varchar.
7575
// see: https://sailsjs.com/documentation/reference/waterline-orm/queries/decrypt
7676
// You will need to "decrypt" the user object before you can check if the password is valid.
7777
// encrypt: true // currently, does not work as intended, as password is encrypted before we can hash it
@@ -80,13 +80,13 @@ module.exports = {
8080
verificationKey: { // placeholder for something like email verification
8181
type: 'string',
8282
allowNull: true,
83-
columnType: 'varchar(191)'
83+
columnType: 'varchar(191)' // 191 is the max length to safely use the utf8mb4 varchar.
8484
},
8585

8686
avatar: {
8787
type: 'string',
8888
isURL: true,
89-
columnType: 'varchar(191)'
89+
columnType: 'varchar(191)' // 191 is the max length to safely use the utf8mb4 varchar.
9090
},
9191

9292
isGravatar: {

assets/src/Admin/Login.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class Login extends Component {
4848
return done(body.user);
4949
}
5050

51-
// This should not happen, as the error handler below should display the error from the server.
51+
// This should not happen, as the `defaultAPIErrorHandler` should display the error from the server.
5252
alert('Unknown error. Please try again. If this error persists, please contact support.');
5353
console.error('Something is wrong in the handleLogin API post...');
5454
}, defaultAPIErrorHandler);

config/ngrok.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66

77
module.exports.ngrok = {
8-
// Set an HTTP basic-auth wall for the app.
8+
// Set an HTTP basic-auth wall for the app. Optional.
99
auth: process.env.NGROK_BASIC || undefined, // Use a string of 'username:password' style (raw password)
1010

1111
// Default Ngrok authtoken, to tie to your account.
@@ -15,10 +15,10 @@ module.exports.ngrok = {
1515
// Whether to build assets by default or not.
1616
buildAssets: true,
1717

18-
// The static domain to use for the Ngrok tunnel. Something like: 'running-grey-gazelle.ngrok-free.app'
18+
// The static domain to use for the Ngrok tunnel. Something like: 'running-grey-gazelle.ngrok-free.app'. Optional; Ngrok can generate a single-use random domain.
1919
domain: process.env.NGROK_DOMAIN || undefined,
2020

21-
// The default region for the Ngrok tunnel.
21+
// The default region for the Ngrok tunnel. Optional.
2222
region: process.env.NGROK_REGION || undefined,
2323

2424
// The default port to start Sails for the Ngrok tunnel.

0 commit comments

Comments
 (0)