This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import LoadingOverlay from './Loader' | |
export default (loader, props) => ( | |
class AsyncComponent extends React.Component { | |
constructor(props) { | |
super(props); | |
this.Component = null; | |
this.state = { Component: AsyncComponent.Component }; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var jwt = require('./jwt'); | |
const checkToken = ( req ) => { | |
//get the http header 'authorization' | |
let authorization = req.get( 'authorization' ); | |
if ( !authorization ) { | |
throw new Error( 401 ) | |
} | |
//check the token signature with 'jwt.js' library | |
let token = authorization.replace( 'Bearer ', '' ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const credentials = require( './credentials.json' ).facebook | |
const { client_id, client_secret } = credentials; | |
var fetch = require( 'node-fetch' ); | |
module.exports.getUser = ( code ) => { | |
let appToken; | |
let url = 'https://graph.facebook.com/oauth/access_token?client_id=' + client_id + '&client_secret=' + client_secret + '&grant_type=client_credentials'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var jwt = require( 'jsonwebtoken' ); | |
const secret = require( './credentials.json' ).jwt.secret | |
var createToken = ( user ) => { | |
return "thisisthetokenof:" + user.id | |
} | |
module.exports.verify = ( token ) => { | |
try { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require( 'express' ); | |
var bodyParser = require( 'body-parser' ); | |
var googleAuth = require( './googleAuth.js' ); | |
var app = express(); | |
var jwt = require('./jwt.js') | |
app.use( bodyParser.json() ); | |
app.use( bodyParser.urlencoded( { extended: false } ) ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const credentials = require( './credentials.json' ) | |
const GOOGLE_CLIENT_ID = credentials.google.client_id; | |
const { OAuth2Client } = require( 'google-auth-library' ); | |
var client = new OAuth2Client( GOOGLE_CLIENT_ID, '', '' ); | |
//return a promise with user informations | |
module.exports.getGoogleUser = ( code ) => { | |
//verify the token using google client | |
return client.verifyIdToken( { idToken: code, audience: GOOGLE_CLIENT_ID } ) | |
.then( login => { |
NewerOlder