You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
+ Setup so Sails will serve Webpack-built bundles as separate apps (so, a marketing site, and an admin site can live side-by-side).
14
-
+ Includes [react-bootstrap](https://www.npmjs.com/package/react-bootstrap) to make using Bootstrap styles / features with React easier.
15
-
+ Schema validation and enforcement for `PRODUCTION`. This repo is set up for `MySQL`. If you plan to use a different datastore, you will likely want to disable the schema validation and enforcement feature inside [`config/bootstrap.js`](config/bootstrap.js). See [schema validation and enforcement](#schema-validation-and-enforcement) for more info.
* Setup so Sails will serve Webpack-built bundles as separate apps (so, a marketing site, and an admin site can live side-by-side).
14
+
* Includes [react-bootstrap](https://www.npmjs.com/package/react-bootstrap) to make using Bootstrap styles / features with React easier.
15
+
* Schema validation and enforcement for `PRODUCTION`. This repo is set up for `MySQL`. If you plan to use a different datastore, you will likely want to disable the schema validation and enforcement feature inside [`config/bootstrap.js`](config/bootstrap.js). See [schema validation and enforcement](#schema-validation-and-enforcement) for more info.
16
+
* New passwords can 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 be forced to choose another. See [PwnedPasswords integration](#pwnedpasswordscom-integration) for more info.
16
17
17
18
## Branch Warning
18
19
The `master` branch is experimental, and the [release branch](https://github.com/neonexus/sails-react-bootstrap-webpack/tree/release) (or the [`releases section`](https://github.com/neonexus/sails-react-bootstrap-webpack/releases)) is where one should base their use of this template.
@@ -70,10 +71,10 @@ If you DO NOT like this behavior, and would prefer the variables stay the same a
| ASSETS_URL | "" (empty string) | Webpack is configured to modify static asset URLs to point to a CDN, like CloudFront. MUST end with a slash " / ", or be empty. |
72
73
| BASE_URL |https://myapi.app| The address of the Sails instance. |
73
-
|**DEV:** DB_HOST<br />**PROD:** DB_HOSTNAME | localhost | The hostname of the datastore. |
74
-
|**DEV:** DB_USER<br />**PROD:** DB_USERNAME |**DEV:** root <br /> **PROD:** produser | Username of the datastore. |
75
-
|**DEV:** DB_PASS<br />**PROD:** DB_PASSWORD |**DEV:** mypass <br /> **PROD:** prodpass | Password of the datastore. |
76
-
| DB_NAME |**DEV:** myapp <br /> **PROD:** prod | The name of the database inside the datastore. |
74
+
| **DEV:** DB_HOST<br />**PROD:** DB_HOSTNAME | localhost | The hostname of the datastore. |
75
+
| **DEV:** DB_USER<br />**PROD:** DB_USERNAME | **DEV:** root <br /> **PROD:** produser | Username of the datastore. |
76
+
| **DEV:** DB_PASS<br />**PROD:** DB_PASSWORD | **DEV:** mypass <br /> **PROD:** prodpass | Password of the datastore. |
77
+
| DB_NAME | **DEV:** myapp <br /> **PROD:** prod | The name of the database inside the datastore. |
77
78
| DB_PORT | 3306 | The port number for the datastore. |
78
79
| DB_SSL | true | If the datastore requires SSL, set this to "true". |
79
80
| SESSION_SECRET | "" (empty string) | Used to sign cookies, and SHOULD be set, especially on PRODUCTION environments. |
When a new password is being created, it is checked with the [PwnedPasswords.com API](https://haveibeenpwned.com/API/v3#PwnedPasswords). This API uses a k-anonymity model, so the password that is searched for is never exposed to the API. Basically, the password is hashed, then the first 5 characters are sent to the API, and the API returns any hashes that start with those 5 characters, including the amount of times that hash (aka password) has been found in known security breaches.
121
+
122
+
This functionality is turned on by default, and can be shutoff per-use, or globally throughout the app. `sails.helpers.isPasswordValid` can be used with `skipPwned` option set to `true`, to disable the check per use. Inside of [`config/security.js`](config/security.js), the variable `checkPwned` can be set to `false` to disable it globally.
123
+
118
124
## What about SEO?
119
125
I recommend looking at [prerender.io](https://prerender.io). They offer a service (free up to 250 pages) that caches the end result of a JavaScript-rendered view (React, Vue, Angular), allowing search engines to crawl otherwise un-crawlable web views. You can use the service in a number of ways. One way, is to use the [prerender-node](https://www.npmjs.com/package/prerender-node) package. To use it with Sails, you'll have to add it to the [HTTP Middleware](https://sailsjs.com/documentation/concepts/middleware#?http-middleware). Here's a quick example:
description: 'Get paginated list of soft-deleted users',
5
+
6
+
inputs: {
7
+
page: {
8
+
description: 'The page number to return',
9
+
type: 'number',
10
+
defaultsTo: 1,
11
+
min: 1
12
+
},
13
+
14
+
limit: {
15
+
description: 'The amount of users to return',
16
+
type: 'number',
17
+
defaultsTo: 25,
18
+
min: 1,
19
+
max: 500
20
+
}
21
+
},
22
+
23
+
exits: {
24
+
ok: {
25
+
responseType: 'ok'
26
+
},
27
+
badRequest: {
28
+
responseType: 'badRequest'
29
+
},
30
+
serverError: {
31
+
responseType: 'serverError'
32
+
}
33
+
},
34
+
35
+
fn: async(inputs,exits)=>{
36
+
constquery=sails.helpers.paginateForQuery.with({
37
+
limit: inputs.limit,
38
+
page: inputs.page,
39
+
where: {
40
+
deletedAt: {'!=': null}// get all soft-deleted users
41
+
},
42
+
sort: 'deletedAt DESC'
43
+
});
44
+
45
+
letout=awaitsails.helpers.paginateForJson.with({
46
+
model: sails.models.user,
47
+
objToWrap: {users: []},// this is the object that will be output to "out", and will contain additional pagination info,
48
+
query
49
+
});
50
+
51
+
// We assign the users to the object afterward, so we can run our safety checks.
52
+
// Otherwise, if we were to put the users object into "objToWrap", they would be transformed, and the "customToJSON" feature would no longer work, and hashed passwords would leak.
// We assign the users to the object afterward, so we can run our safety checks.
50
48
// Otherwise, if we were to put the users object into "objToWrap", they would be transformed, and the "customToJSON" feature would no longer work, and hashed passwords would leak.
0 commit comments