Commit c74fde23d11245b650db36ddad31c10619c40368

Authored by Ryan Glover
Exists in master

Merge branch 'refactor/update_iron_router'

1 # Meteor packages used by this project, one per line. 1 # Meteor packages used by this project, one per line.
2 # 2 #
3 # 'meteor add' and 'meteor remove' will edit this file for you, 3 # 'meteor add' and 'meteor remove' will edit this file for you,
4 # but you can also edit it by hand. 4 # but you can also edit it by hand.
5 5
6 standard-app-packages 6 standard-app-packages
7 coffeescript 7 coffeescript
8 underscore 8 underscore
9 accounts-password 9 accounts-password
10 accounts-base 10 accounts-base
11 jquery 11 jquery
12 check 12 check
13 audit-argument-checks 13 audit-argument-checks
14 iron:router 14 iron:router
15 pinglamb:bootstrap3 15 pinglamb:bootstrap3
16 particle4dev:sass
17 cmather:handlebars-server 16 cmather:handlebars-server
18 themeteorchef:jquery-validation 17 themeteorchef:jquery-validation
18 particle4dev:sass@0.3.0
19 19
1 accounts-base@1.1.2 1 accounts-base@1.1.2
2 accounts-password@1.0.4 2 accounts-password@1.0.4
3 application-configuration@1.0.3 3 application-configuration@1.0.3
4 audit-argument-checks@1.0.1 4 audit-argument-checks@1.0.1
5 autoupdate@1.1.3 5 autoupdate@1.1.3
6 base64@1.0.1 6 base64@1.0.1
7 binary-heap@1.0.1 7 binary-heap@1.0.1
8 blaze-tools@1.0.1 8 blaze-tools@1.0.1
9 blaze@2.0.3 9 blaze@2.0.3
10 boilerplate-generator@1.0.1 10 boilerplate-generator@1.0.1
11 callback-hook@1.0.1 11 callback-hook@1.0.1
12 check@1.0.2 12 check@1.0.2
13 cmather:handlebars-server@2.0.0 13 cmather:handlebars-server@2.0.0
14 coffeescript@1.0.4 14 coffeescript@1.0.4
15 ctl-helper@1.0.4 15 ctl-helper@1.0.4
16 ctl@1.0.2 16 ctl@1.0.2
17 ddp@1.0.11 17 ddp@1.0.11
18 deps@1.0.5 18 deps@1.0.5
19 ejson@1.0.4 19 ejson@1.0.4
20 email@1.0.4 20 email@1.0.4
21 fastclick@1.0.1 21 fastclick@1.0.1
22 follower-livedata@1.0.2 22 follower-livedata@1.0.2
23 geojson-utils@1.0.1 23 geojson-utils@1.0.1
24 handlebars@1.0.1 24 handlebars@1.0.1
25 html-tools@1.0.2 25 html-tools@1.0.2
26 htmljs@1.0.2 26 htmljs@1.0.2
27 http@1.0.8 27 http@1.0.8
28 id-map@1.0.1 28 id-map@1.0.1
29 iron:core@0.3.4 29 iron:controller@1.0.0
30 iron:dynamic-template@0.4.1 30 iron:core@1.0.0
31 iron:layout@0.4.1 31 iron:dynamic-template@1.0.0
32 iron:router@0.9.4 32 iron:layout@1.0.0
33 iron:location@1.0.0
34 iron:middleware-stack@1.0.0
35 iron:router@1.0.0
36 iron:url@1.0.0
33 jquery@1.0.1 37 jquery@1.0.1
34 json@1.0.1 38 json@1.0.1
35 launch-screen@1.0.0 39 launch-screen@1.0.0
36 livedata@1.0.11 40 livedata@1.0.11
37 localstorage@1.0.1 41 localstorage@1.0.1
38 logging@1.0.5 42 logging@1.0.5
39 meteor-platform@1.2.0 43 meteor-platform@1.2.0
40 meteor@1.1.3 44 meteor@1.1.3
41 minifiers@1.1.2 45 minifiers@1.1.2
42 minimongo@1.0.5 46 minimongo@1.0.5
43 mobile-status-bar@1.0.1 47 mobile-status-bar@1.0.1
44 mongo@1.0.8 48 mongo@1.0.8
45 npm-bcrypt@0.7.7 49 npm-bcrypt@0.7.7
46 observe-sequence@1.0.3 50 observe-sequence@1.0.3
47 ordered-dict@1.0.1 51 ordered-dict@1.0.1
48 particle4dev:sass@0.3.0 52 particle4dev:sass@0.3.0
49 pinglamb:bootstrap3@3.2.1 53 pinglamb:bootstrap3@3.2.1
50 random@1.0.1 54 random@1.0.1
51 reactive-dict@1.0.4 55 reactive-dict@1.0.4
52 reactive-var@1.0.3 56 reactive-var@1.0.3
53 reload@1.1.1 57 reload@1.1.1
54 retry@1.0.1 58 retry@1.0.1
55 routepolicy@1.0.2 59 routepolicy@1.0.2
56 service-configuration@1.0.2 60 service-configuration@1.0.2
57 session@1.0.4 61 session@1.0.4
58 sha@1.0.1 62 sha@1.0.1
59 spacebars-compiler@1.0.3 63 spacebars-compiler@1.0.3
60 spacebars@1.0.3 64 spacebars@1.0.3
61 srp@1.0.1 65 srp@1.0.1
62 standard-app-packages@1.0.3 66 standard-app-packages@1.0.3
63 templating@1.0.9 67 templating@1.0.9
64 themeteorchef:jquery-validation@1.13.1 68 themeteorchef:jquery-validation@1.13.1
65 tracker@1.0.3 69 tracker@1.0.3
66 ui@1.0.4 70 ui@1.0.4
67 underscore@1.0.1 71 underscore@1.0.1
68 url@1.0.2 72 url@1.0.2
69 webapp-hashing@1.0.1 73 webapp-hashing@1.0.1
70 webapp@1.1.4 74 webapp@1.1.4
71 75
client/routes/filters.coffee
1 ### 1 ###
2 Route Filters 2 Route Filters
3 Filters for managing user access to application routes. 3 Filters for managing user access to application routes.
4 ### 4 ###
5 5
6 # Define Filters 6 # Define Filters
7 7
8 ### 8 ###
9 Filter: Check if a User is Logged In 9 Filter: Check if a User is Logged In
10 If a user is not logged in and attempts to go to an authenticated route, 10 If a user is not logged in and attempts to go to an authenticated route,
11 re-route them to the login screen. 11 re-route them to the login screen.
12 ### 12 ###
13 checkUserLoggedIn = -> 13 checkUserLoggedIn = ->
14 if not Meteor.loggingIn() and not Meteor.user() 14 if not Meteor.loggingIn() and not Meteor.user()
15 Router.go '/login' 15 Router.go '/login'
16 @pause 16 else
17 @next()
17 18
18 ### 19 ###
19 Filter: Check if a User Exists 20 Filter: Check if a User Exists
20 If a user is logged in and attempts to go to a public route, re-route 21 If a user is logged in and attempts to go to a public route, re-route
21 them to the main "logged in" screen. 22 them to the main "logged in" screen.
22 ### 23 ###
23 userAuthenticated = -> 24 userAuthenticated = ->
24 if not Meteor.loggingIn() and Meteor.user() 25 if not Meteor.loggingIn() and Meteor.user()
25 Router.go '/' 26 Router.go '/'
27 else
28 @next()
26 29
27 # Run Filters 30 # Run Filters
28
29 Router.onBeforeAction checkUserLoggedIn, except: [ 31 Router.onBeforeAction checkUserLoggedIn, except: [
30 'signup', 32 'signup',
31 'login', 33 'login',
32 'recover-password', 34 'recover-password',
33 'reset-password' 35 'reset-password'
34 ] 36 ]
35 37
36 Router.onBeforeAction userAuthenticated, only: [ 38 Router.onBeforeAction userAuthenticated, only: [
37 'signup', 39 'signup',
38 'login', 40 'login',
39 'recover-password', 41 'recover-password',
40 'reset-password' 42 'reset-password'
41 ] 43 ]
client/routes/routes-authenticated.coffee
1 Router.map(-> 1 Router.route('index',
2 @route('index', 2 path: '/'
3 path: '/' 3 template: 'index'
4 template: 'index' 4 onBeforeAction: ->
5 onBeforeAction: -> 5 # Code to run before route goes here.
6 # Code to run before route goes here. 6 @next()
7 )
8 ) 7 )
9 8
client/routes/routes-public.coffee
1 Router.map(-> 1 Router.route('signup',
2 2 path: '/signup'
3 @route('signup', 3 template: 'signup'
4 path: '/signup' 4 onBeforeAction: ->
5 template: 'signup' 5 Session.set 'currentRoute', 'signup'
6 onBeforeAction: -> 6 @next()
7 Session.set 'currentRoute', 'signup' 7 )
8 )
9 8
10 @route('login', 9 Router.route('login',
11 path: '/login' 10 path: '/login'
12 template: 'login' 11 template: 'login'
13 onBeforeAction: -> 12 onBeforeAction: ->
14 Session.set 'currentRoute', 'login' 13 Session.set 'currentRoute', 'login'
15 ) 14 @next()
15 )
16 16
17 @route('recover-password', 17 Router.route('recover-password',
18 path: '/recover-password' 18 path: '/recover-password'
19 template: 'recoverPassword' 19 template: 'recoverPassword'
20 onBeforeAction: -> 20 onBeforeAction: ->
21 Session.set 'currentRoute', 'recover-password' 21 Session.set 'currentRoute', 'recover-password'
22 ) 22 @next()
23 )
23 24
24 @route('reset-password', 25 Router.route('reset-password',
25 path: '/reset-password/:token' 26 path: '/reset-password/:token'
26 template: 'resetPassword' 27 template: 'resetPassword'
27 onBeforeAction: -> 28 onBeforeAction: ->
28 Session.set 'currentRoute', 'reset-password' 29 Session.set 'currentRoute', 'reset-password'
29 Session.set 'resetPasswordToken', @params.token 30 Session.set 'resetPasswordToken', @params.token
30 ) 31 @next()
31 ) 32 )