Created
May 8, 2015 15:21
-
-
Save boxxa/33618f2afac3a167a53f to your computer and use it in GitHub Desktop.
Iron-Router Session Variable Hook
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Meteor.call('setStatus', statusMessage, function(error, result){ | |
if(result) | |
{ | |
Session.set('isAway', true) | |
Router.go('/') | |
} else { | |
Router.go('/error') | |
} | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
onBeforeAction: function () { | |
var self = this; | |
if(Meteor.userId()) | |
{ | |
Meteor.call('checkStatus',function(error,result){ | |
if(result) | |
{ | |
Session.set('isAway',true) | |
self.render('awayPage') | |
} else { | |
Session.set('isAway', false) | |
} | |
}) | |
} | |
this.next() | |
}, | |
action: function() | |
{ | |
if(Session.set('isAway',true)) | |
this.render('awayPage') | |
else | |
this.render('homePage') | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment