Skip to content

Instantly share code, notes, and snippets.

@khades
Created June 28, 2016 19:59
Show Gist options
  • Save khades/137341b6a9a33f40cd8f3da5b9ca0ff8 to your computer and use it in GitHub Desktop.
Save khades/137341b6a9a33f40cd8f3da5b9ca0ff8 to your computer and use it in GitHub Desktop.
var Auth = {
route: function(component) {
return {
controller: function() {
/* eslint consistent-return: 0 */
var info = ProfileInfoModel
var redirect = function() {
if (ProfileInfoModel.profile.auth == false) {
Auth.redirectTo = m.route()
console.log(Auth.redirectTo)
return m.route("/login");
}
}
ProfileInfoModel.getUserInfoPromise.then(function(success) {
redirect()
}, function(error) {
redirect()
})
},
view: function() {
return m.component(component);
}
}
}.bind(this)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment