lib/express-auth.js
function trigger_service_login (msg, respond) {
    var seneca = this

    if (!msg.user) {
      return respond(null, {ok: false, why: 'no-user'})
    }

    var user_data = msg.user
    var q = {}
    if (user_data.identifier) {
      q[msg.service + '_id'] = user_data.identifier
      user_data[msg.service + '_id'] = user_data.identifier
    }
    else {
      return respond(null, {ok: false, why: 'no-identifier'})
    }

    seneca.act("role: 'user', get: 'user'", q, function (err, data) {
      if (err) return respond(null, {ok: false, why: 'no-identifier'})

      if (!data.ok) return respond(null, {ok: false, why: data.why})

      var user = data.user
      if (!user) {
        seneca.act("role:'user',cmd:'register'", user_data, function (err, out) {
          if (err) {
            return respond(null, {ok: false, why: err})
          }

          respond(null, out.user)
        })
      }
      else {
        seneca.act("role:'user',cmd:'update'", user_data, function (err, out) {
          if (err) {
            return respond(null, {ok: false, why: err})
          }

          respond(null, out.user)
        })
      }
    })
  }
function trigger_service_login (msg, respond) {
    var seneca = this

    if (!msg.user) {
      return respond(null, {ok: false, why: 'no-user'})
    }

    var user_data = msg.user
    var q = {}
    if (user_data.identifier) {
      q[msg.service + '_id'] = user_data.identifier
      user_data[msg.service + '_id'] = user_data.identifier
    }
    else {
      return respond(null, {ok: false, why: 'no-identifier'})
    }

    seneca.act("role: 'user', get: 'user'", q, function (err, data) {
      if (err) return respond(null, {ok: false, why: 'no-identifier'})

      if (!data.ok) return respond(null, {ok: false, why: data.why})

      var user = data.user
      if (!user) {
        seneca.act("role:'user',cmd:'register'", user_data, function (err, out) {
          if (err) {
            return respond(null, {ok: false, why: err})
          }

          respond(null, out.user)
        })
      }
      else {
        seneca.act("role:'user',cmd:'update'", user_data, function (err, out) {
          if (err) {
            return respond(null, {ok: false, why: err})
          }

          respond(null, out.user)
        })
      }
    })
  }
function trigger_service_login ( msg , respond ) { var seneca = this if ( ! msg . user ) { return respond ( null , { ok : false , why : 'no-user' } ) } var user_data = msg . user var q = { } if ( user_data . identifier ) { q [ msg . service + '_id' ] = user_data . identifier user_data [ msg . service + '_id' ] = user_data . identifier } else { return respond ( null , { ok : false , why : 'no-identifier' } ) } seneca . act ( "role: 'user', get: 'user'" , q , function ( err , data ) { if ( err ) return respond ( null , { ok : false , why : 'no-identifier' } ) if ( ! data . ok ) return respond ( null , { ok : false , why : data . why } ) var user = data . user if ( ! user ) { seneca . act ( "role:'user',cmd:'register'" , user_data , function ( err , out ) { if ( err ) { return respond ( null , { ok : false , why : err } ) } respond ( null , out . user ) } ) } else { seneca . act ( "role:'user',cmd:'update'" , user_data , function ( err , out ) { if ( err ) { return respond ( null , { ok : false , why : err } ) } respond ( null , out . user ) } ) } } ) }
LOGOUT END default service login trigger
LOGOUT END default service login trigger