Created
November 6, 2014 20:56
-
-
Save ralt/d0be3c04223e17e40397 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
// example of how you do stuff as user x | |
route('/dashboard', function() { loadDashboard(getSession('user_id')); }); | |
// example of link to become another user | |
// make sure it's admin only | |
route('/changelink/:userid', requireAdmin, function(req) { | |
setSession('is_faking', getSession('user_id')); | |
setSession('user_id', req.params.userid); | |
}); | |
// in template | |
{{ if getSession('is_faking') }} | |
<a href="/fakelogout">go back to admin</a> | |
{{ endif }} | |
route('/fakelogout', function(req) { | |
// don't forget to check... | |
if (!getSession('is_faking')) return; | |
setSession('user_id', getSession('is_faking')); | |
unsetSession('is_faking'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment