index.js
function login(options) {
  const defaultHost = options.host;
  return async function loginHandler(ctx) {
    const loginCallbackPath = options.loginCallbackPath;
    const loginPath = options.loginPath;
    // ctx.session should be exists
    if (ctx.session) {
      ctx.session.userauthLoginReferer = formatReferer(ctx, loginPath, options.rootPath);
      debug('set loginReferer into session: %s', ctx.session.userauthLoginReferer);
    }

    const host = defaultHost || ctx.host;
    const protocol = options.protocol || ctx.protocol;
    const currentURL = protocol + '://' + host + loginCallbackPath;
    const loginURL = options.loginURLFormatter(currentURL, options.rootPath, ctx);
    debug('login redrect to loginURL: %s', loginURL);
    redirect(ctx, loginURL);
  };
}
function login(options) {
  const defaultHost = options.host;
  return async function loginHandler(ctx) {
    const loginCallbackPath = options.loginCallbackPath;
    const loginPath = options.loginPath;
    // ctx.session should be exists
    if (ctx.session) {
      ctx.session.userauthLoginReferer = formatReferer(ctx, loginPath, options.rootPath);
      debug('set loginReferer into session: %s', ctx.session.userauthLoginReferer);
    }

    const host = defaultHost || ctx.host;
    const protocol = options.protocol || ctx.protocol;
    const currentURL = protocol + '://' + host + loginCallbackPath;
    const loginURL = options.loginURLFormatter(currentURL, options.rootPath, ctx);
    debug('login redrect to loginURL: %s', loginURL);
    redirect(ctx, loginURL);
  };
}
function login ( options ) { const defaultHost = options . host ; return async function loginHandler ( ctx ) { const loginCallbackPath = options . loginCallbackPath ; const loginPath = options . loginPath ; // ctx.session should be exists if ( ctx . session ) { ctx . session . userauthLoginReferer = formatReferer ( ctx , loginPath , options . rootPath ) ; debug ( 'set loginReferer into session: %s' , ctx . session . userauthLoginReferer ) ; } const host = defaultHost || ctx . host ; const protocol = options . protocol || ctx . protocol ; const currentURL = protocol + '://' + host + loginCallbackPath ; const loginURL = options . loginURLFormatter ( currentURL , options . rootPath , ctx ) ; debug ( 'login redrect to loginURL: %s' , loginURL ) ; redirect ( ctx , loginURL ) ; } ; }
return a loginHandler
@param {Object} options
@return {Function}
return a loginHandler