nl_tokens: Framework to register OAuth providers with passport
pl_tokens: function registerProvider ( provider , configFunction ) { provider = provider . toLowerCase ( ) ; var configRef = 'providers.' + provider ; if ( config . getItem ( configRef + '.credentials' ) ) { var credentials = config . getItem ( configRef + '.credentials' ) ; credentials . passReqToCallback = true ; var options = config . getItem ( configRef + '.options' ) || { } ; configFunction . call ( null , credentials , passport , authHandler ) ; router . get ( '/' + provider , passportCallback ( provider , options , 'login' ) ) ; router . get ( '/' + provider + '/callback' , passportCallback ( provider , options , 'login' ) , initSession , oauthErrorHandler ) ; if ( ! config . getItem ( 'security.disableLinkAccounts' ) ) { router . get ( '/link/' + provider , passport . authenticate ( 'bearer' , { session : false } ) , passportCallback ( provider , <mask> , 'link' ) ) ; router . get ( '/link/' + provider + '/callback' , passport . authenticate ( 'bearer' , { session : false } ) , passportCallback ( provider , options , 'link' ) , linkSuccess , oauthErrorHandler ) ; } console . log ( provider + ' loaded.' ) ; } }