just-login-bypass
v1.0.0
Published
When developing an application that uses Just Login, use this to bypass authentication in dev
Downloads
2
Maintainers
Readme
just-login-bypass
When developing an application that uses Just Login, use this to bypass authentication in dev
A replacement for the just-login-emailer. Instead of emailing you when you click 'Login', it will just log you in as whomever. Don't use this in production. :)
With npm do:
npm install just-login-bypass
api
var bypass = require('just-login-bypass')
bypass(core, [...,] [cb])
Takes a just-login-core object.
The last function passed in is used as a callback.
Any other options are ignored, so you can use it instead of the just-login-emailer.
example
index.js
var PROD = !(process.env.dev || process.argv[2] === '--dev')
var Level = require('level')
var JustLogin = require('just-login-core')
var customEmails = require('./custom-emailer-opts.js')
var emailer = require( PROD ? 'just-login-emailer' : 'just-login-bypass' )
var db = new Level('./database')
var core = JustLogin(db)
customEmails(core, emailer)
custom-emailer-opts.js
module.exports = function customEmails(core, emailer) {
function makeEmail(token) {
return 'Copy & paste this into your browser: ' +
'http://example.com/login?token=' + token
}
var transportOpts = {
host: "smtp.gmail.com",
port: 465,
secure: true,
auth: { user: "[email protected]", pass: "pass" }
}
var mailOpts = { from: '[email protected]', subject: 'sign in' }
emailer(core, makeEmail, transportOpts, mailOpts, function (err, info) {
if (err) console.error(err)
})
}