Blame view
client/routes/filters.coffee
856 Bytes
d1f4dbea8
|
1 |
### |
5f6f6fbb0
|
2 3 |
Route Filters Filters for managing user access to application routes. |
d1f4dbea8
|
4 5 6 |
### # Define Filters |
98c57048b
|
7 |
### |
5f6f6fbb0
|
8 9 10 |
Filter: Check if a User is Logged In If a user is not logged in and attempts to go to an authenticated route, re-route them to the login screen. |
98c57048b
|
11 |
### |
d1f4dbea8
|
12 |
checkUserLoggedIn = -> |
5f6f6fbb0
|
13 14 15 |
if not Meteor.loggingIn() and not Meteor.user() Router.go '/login' @pause |
d1f4dbea8
|
16 |
|
98c57048b
|
17 |
### |
5f6f6fbb0
|
18 19 20 |
Filter: Check if a User Exists If a user is logged in and attempts to go to a public route, re-route them to the main "logged in" screen. |
98c57048b
|
21 |
### |
d1f4dbea8
|
22 |
userAuthenticated = -> |
5f6f6fbb0
|
23 24 |
if not Meteor.loggingIn() and Meteor.user() Router.go '/' |
d1f4dbea8
|
25 |
|
d1f4dbea8
|
26 27 28 |
# Run Filters Router.onBeforeAction checkUserLoggedIn, except: [ |
5f6f6fbb0
|
29 30 31 32 |
'signup', 'login', 'recover-password', 'reset-password' |
d1f4dbea8
|
33 34 35 |
] Router.onBeforeAction userAuthenticated, only: [ |
5f6f6fbb0
|
36 37 38 39 |
'signup', 'login', 'recover-password', 'reset-password' |
d1f4dbea8
|
40 |
] |