Skip to content

Instantly share code, notes, and snippets.

@zenlor
Last active July 7, 2016 14:44
Show Gist options
  • Save zenlor/450fb654bfa91ffe6231768ae75b7558 to your computer and use it in GitHub Desktop.
Save zenlor/450fb654bfa91ffe6231768ae75b7558 to your computer and use it in GitHub Desktop.
lispy js failure
// People should take a look at lisp
// this code would be much more readable
exports.handler = function handler(request, reply) {
const code = request.query.code;
const state = request.query.state;
const stateLink = (new Buffer(state, 'base64')).toString('utf8');
const key = getUserKey(state);
const id = getId(state);
getToken(key,
id,
code,
state)
.then(customer =>
reply.view('index', { customer, state: stateLink }))
.catch(err =>
(isCodeExpired(err)
// render `expired_code` for users waiting too long to login
? reply.view('expired_code')
// Unknown error
: reply(normalizeErrors(err))));
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment