Giter Club home page Giter Club logo

angular-passport-auth-sio's Introduction

Access Passport.js user information from socket.io connection using angular as client. Angular-Passport-Auth-SIO

This is a fork from the following

Major League help from Michael Robinson at faceleg

This is a complete demonstration of express.io, passport, passport.socketio, firebird sql and angular.

I've included all the code for those it might help.

Notes:

  • To install in windows from command prompt

  • md nodedemo

  • cd nodedemo

  • git clone https://github.com/johntom/Angular-Passport-Auth-SIO

  • npm install

  • node server

  • install firebird and copy from adjuster.gdb from \database to wherever desired and change \Angular-Passport-Auth-SIO\server\models\cfg\cfg.json

  • in browser http://localhost:8000

  • [Firebird] (http://firebirdsql.org) (http://ibphoeninx.com) open source sql database and can easily be replaced by mysql.

  • [https://github.com/hgourvest/node-firebird] Henri Gourvest essential repo for using node with firebird

  • I use the database for local authentication (see \Server\Models\User.js)

  • socket.js uses the authenication credentials to bring only the data for logged in user. See \Server\socket.js and Usage

  • I will refactor this code asap to make it more efficient

Usage

    socket.on('getclaims', function (data) {
        var user = socket.handshake.session;//.user_id;
        var adj = user.req.session.req.user.adjusterid; // added to passport
        console.log('== get only open claims for authenticated useer ', adj)
        qrystr = 'select CLAIM_ID "id", CLAIM_NO "title" , INSURED_ID, CLAIM_TYPE "type", ADJUSTER_ID, ACCOUNT_REP_ID "reporter" , INSURANCE_COMPANY_ID "assignee"  , \
            description,status "status",   DATE_OF_LOSS, POLICY_NUMBER,REPORTED,RECOVERY_COMMENTS,RECEIVED from CLAIM where ADJUSTER_ID= ? and status = 1 ';
        console.log('qrystr: ', qrystr, [adj ]);
        console.log('==============================================================');
        database.execute(qrystr, [adj], function (err, results, fields) {
            var jsondata = new Array();
            wrapJson(results, fields, jsondata);
            output = {"Claims": jsondata};
            socket.emit('initclaims', output);
        });

    });
...

Thanks to all who helped.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.