function login (loginOptions) {
  // Login options
  loginOptions = defaults(loginOptions, {
    user: null,
    pass: null,
    base: null,
    signinPath: '/entry/signin',
  })

  // Return the whole thing so it can be used
  // with an ongoing promise chain
  return request.get({
    url: options.base + options.signinPath,
  }).then(function ($) {
    // Fetch the Transient Key
    var transientKey = $('#Form_TransientKey').val()

    // Build the form data
    var data = {
      'hpt': '',
      'Target': '/',
      'TransientKey': transientKey,
      'Email': options.user,
      'Password': options.pass,
      'Sign In': 'Sign In',
    }

    // Submit the request
    return request.post({
      url: options.base + options.signinPath,
      form: data,
      followAllRedirects: true,
    })
  })
}
/**
 * Utility function to log into a Vanilla install
 */
Utility function to log into a Vanilla install
Utility function to log into a Vanilla install
function login (loginOptions) {
  loginOptions = defaults(loginOptions, {
    user: null,
    pass: null,
    base: null,
    signinPath: '/entry/signin',
  })
  return request.get({
    url: options.base + options.signinPath,
  }).then(function ($) {
    var transientKey = $('#Form_TransientKey').val()
    var data = {
      'hpt': '',
      'Target': '/',
      'TransientKey': transientKey,
      'Email': options.user,
      'Password': options.pass,
      'Sign In': 'Sign In',
    }
    return request.post({
      url: options.base + options.signinPath,
      form: data,
      followAllRedirects: true,
    })
  })
}
function login ( loginOptions ) { loginOptions = defaults ( loginOptions , { user : null , pass : null , base : null , signinPath : '/entry/signin' , } ) return request . get ( { url : options . base + options . signinPath , } ) . then ( function ( $ ) { var transientKey = $ ( '#Form_TransientKey' ) . val ( ) var data = { 'hpt' : '' , 'Target' : '/' , 'TransientKey' : transientKey , 'Email' : options . user , 'Password' : options . pass , 'Sign In' : 'Sign In' , } return request . post ( { url : options . base + options . signinPath , form : data , followAllRedirects : true , } ) } ) }
Utility function to log into a Vanilla install
Utility function to log into a Vanilla install
// Login options // Return the whole thing so it can be used // with an ongoing promise chain // Fetch the Transient Key // Build the form data // Submit the request