diff --git a/lib/extensions/index.js b/lib/extensions/index.js index 41a45dc..47d7085 100644 --- a/lib/extensions/index.js +++ b/lib/extensions/index.js @@ -156,12 +156,14 @@ module.exports.pairRequest = function (opts) { , aud: state.config.webminDomain , iat: Math.round(now / 1000) , id: authReq.id + , sub: authReq.subject , pin: pin , hostname: authReq.hostname }; auth = { id: authReq.id , secret: authReq.secret + , subject: authReq.subject , pin: pin , dt: now , exp: now + (2 * 60 * 60 * 1000) @@ -179,10 +181,14 @@ module.exports.pairPin = function (opts) { return state.Promise.resolve().then(function () { var pin = opts.pin; var secret = opts.secret; - var auth = Auths.getBySecretAndPin(secret, pin); + var auth = Auths.getBySecret(secret); if (!auth) { - throw new Error("I can't even right now - bad magic link or pairing code"); + throw new Error("Invalid magic link token '" + secret + "'"); + } + auth = Auths.getBySecretAndPin(secret, pin); + if (!auth) { + throw new Error("Invalid pairing code '" + pin + "' for magic link token '" + secret + "'"); } if (auth._offered) {