Skip to content

Instantly share code, notes, and snippets.

@ralt
Created November 6, 2014 20:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ralt/d0be3c04223e17e40397 to your computer and use it in GitHub Desktop.
Save ralt/d0be3c04223e17e40397 to your computer and use it in GitHub Desktop.
// 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