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
Copy file name to clipboardExpand all lines: readme.md
+21-17
Original file line number
Diff line number
Diff line change
@@ -20,29 +20,29 @@ Have a look at the source code: https://github.com/DaftMonk/fullstack-demo
20
20
## Usage
21
21
22
22
Install `generator-angular-fullstack`:
23
-
```
23
+
```bash
24
24
npm install -g generator-angular-fullstack
25
25
```
26
26
27
27
Make a new directory, and `cd` into it:
28
-
```
28
+
```bash
29
29
mkdir my-new-project &&cd$_
30
30
```
31
31
32
32
Run `yo angular-fullstack`, optionally passing an app name:
33
-
```
33
+
```bash
34
34
yo angular-fullstack [app-name]
35
35
```
36
36
37
37
## Express
38
38
39
39
Launch your express server in development mode.
40
-
```
40
+
```bash
41
41
grunt serve
42
42
```
43
43
44
44
Launch your express server in production mode, uses the minified/optimized production folder.
45
-
```
45
+
```bash
46
46
grunt serve:dist
47
47
```
48
48
@@ -54,13 +54,17 @@ grunt serve:dist
54
54
55
55
To generate a dist folder that can easily be deployed use:
56
56
57
-
grunt
57
+
```bash
58
+
grunt
59
+
```
58
60
59
61
This will run unit tests, jshint, concatenate and minify scripts/css, compress images, add css vendor prefixes, and finally copy all files to a tidy dist folder.
60
62
61
63
Alternatively to skip tests and jshint, use:
62
64
63
-
grunt build
65
+
```bash
66
+
grunt build
67
+
```
64
68
65
69
### Heroku Deployment
66
70
@@ -84,27 +88,27 @@ That's it! Your app should be live and shareable. Type `heroku open` to view it.
84
88
85
89
## Setting up Route authorization
86
90
87
-
If your app uses the Passport boilerplate for accounts, you'll of course want to restrict access to certain client routes/api routes.
91
+
If your app uses the Passport boilerplate for accounts, you will want to restrict access to certain client routes/api routes.
88
92
89
-
For protecting server API routes, we can use the `auth` middleware, which will send a 401 unauthorized error if a user makes a request without being logged in.
93
+
For restricting server API routes, we can use the `auth` middleware, which will send a 401 unauthorized error if a request is made from someone thats not logged in.
90
94
91
-
For protecting client routes, we automatically handle 401s sent from the server by redirecting you to the login page.
95
+
For restricting routes on the client side, we automatically handle 401s sent from the server by redirecting you to the login page.
92
96
93
97
However, as this will load part of the page before redirecting, it will cause a flicker. So this should only be used as a fallback mechanism. A better way to handle restricted pages is to mark the routes on the client side that you want to require authentication for.
94
98
95
-
You can easily do this from your `app.js` by adding the following to any client routes that need protecting.
99
+
You can do this from your `app.js` by adding the following to any client routes that you want to restrict to logged in users.
96
100
97
-
authenticate: true
101
+
```
102
+
authenticate: true
103
+
```
98
104
99
105
This redirects the user to the login page before attempting to load the new route, avoiding the flicker.
100
106
101
-
Please keep in mind this client routing is only for improving the **user interface**. Anyone with chrome developer tools can easily get around it and view pages they're not supposed to see.
102
-
103
-
This is not a problem as long as you **secure your server API** routes, ensuring that you don't give any sensitive information unless the user is authenticated or authorized.
107
+
Please keep in mind this client routing is only for improving the user interface. Make sure you **secure your server API** routes and don't give any sensitive information unless the user is authenticated or authorized.
104
108
105
-
#### How do I only let users authorized access an api route?
109
+
#### How do I only let authorized users access an api route?
106
110
107
-
Similarly to how the `auth` middleware checks if a user authenticated before going to the next route, you could easily make an ensureAuthorized middleware that checks the users role, or some other field, before sending them to the protected route, otherwise it sends a `403` error.
111
+
Similarly to how the `auth` middleware checks if a user authenticated before going to the next route, you can make an ensureAuthorized middleware that checks the users role, or some other field, before sending them to the protected route, otherwise have it sends a `403` error.
0 commit comments