Created
June 28, 2016 19:59
-
-
Save khades/137341b6a9a33f40cd8f3da5b9ca0ff8 to your computer and use it in GitHub Desktop.
This file contains 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
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