Skip to content

djoamersfoort/djo-login-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DJO Login

Express middleware for the DJO oauth server

You can find the scopes at LedenAdministratie

Example

Express

const express = require('express')
const login = require('@djoamersfoort/djo-login-js')

const djo = new login(CLIENT_ID, CLIENT_SECRET, REDIRECT_URI, SCOPES)
const app = express()
// use djo.session instead of another session library for express
app.use(djo.session)

app.get('/', djo.requireLogin, (req, res) => {
  res.send(`Hello ${req.session.djo.firstName}`)
})

// required
app.get('/callback', djo.callback)

app.listen(3000)

Socket.io

const express = require('express')
const socket = require('socket.io')
const login = require('@djoamersfoort/djo-login-js')

const djo = new login(CLIENT_ID, CLIENT_SECRET, REDIRECT_URI, SCOPES)
const app = express()
const server = app.listen(3000)
const io = socket(server)
io.use(djo.socketSession)

io.on('connection', socket => {
    socket.on('isSignedIn', () => {
        if (typeof socket.request.session.user === 'undefined') return
        
        socket.emit('name', socket.request.session.djo.firstName)
    })
})

Installation

npm i djoamersfoort/djo-login-js

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •