Skip to content

Commit

Permalink
init commit
Browse files Browse the repository at this point in the history
  • Loading branch information
djpeach committed Oct 3, 2019
0 parents commit af5961c
Show file tree
Hide file tree
Showing 16 changed files with 15,877 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
**/node_modules/**
.DS_Store
**/DS_Store
29 changes: 29 additions & 0 deletions client/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# client

## Project setup
```
npm install
```

### Compiles and hot-reloads for development
```
npm run serve
```

### Compiles and minifies for production
```
npm run build
```

### Run your tests
```
npm run test
```

### Lints and fixes files
```
npm run lint
```

### Customize configuration
See [Configuration Reference](https://cli.vuejs.org/config/).
5 changes: 5 additions & 0 deletions client/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
presets: [
'@vue/app'
]
}
11,373 changes: 11,373 additions & 0 deletions client/package-lock.json

Large diffs are not rendered by default.

29 changes: 29 additions & 0 deletions client/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "client",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build"
},
"dependencies": {
"axios": "^0.19.0",
"core-js": "^2.6.5",
"firebase": "^7.1.0",
"vue": "^2.6.10"
},
"devDependencies": {
"@vue/cli-plugin-babel": "^3.11.0",
"@vue/cli-service": "^3.11.0",
"vue-template-compiler": "^2.6.10"
},
"postcss": {
"plugins": {
"autoprefixer": {}
}
},
"browserslist": [
"> 1%",
"last 2 versions"
]
}
Binary file added client/public/favicon.ico
Binary file not shown.
18 changes: 18 additions & 0 deletions client/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<title>client</title>
</head>
<body>
<noscript>
<strong>We're sorry but client doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>
28 changes: 28 additions & 0 deletions client/src/App.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<template>
<div id="app">
<img alt="Vue logo" src="./assets/logo.png">
<HelloWorld msg="Welcome to Your Vue.js App"/>
</div>
</template>

<script>
import HelloWorld from './components/HelloWorld.vue'
export default {
name: 'app',
components: {
HelloWorld
}
}
</script>

<style>
#app {
font-family: 'Avenir', Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
}
</style>
Binary file added client/src/assets/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
82 changes: 82 additions & 0 deletions client/src/components/HelloWorld.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<template>
<div class="hello">
<h1>{{ msg }}</h1>
<p class="lead mt-2">{{ authStatus }}</p>
<div class="d-flex my-4 justify-content-center">
<button @click="signIn" class="btn btn-outline-primary mx-4">Sign In ></button>
<button @click="sendRequest" class="btn btn-outline-success mx-4">Send Request ></button>
<button @click="signOut" class="btn btn-outline-danger mx-4">Sign Out ></button>
</div>
<p class="lead">{{ response }}</p>
</div>
</template>

<script>
import axios from 'axios'
import firebase from 'firebase'
const client = axios.create({
baseURL: 'http://localhost:3000',
json: true
})
export default {
name: 'HelloWorld',
data: function() {
return {
response: 'No data yet...',
authStatus: 'No Auth Status'
}
},
props: {
msg: String
},
methods: {
sendRequest() {
if (firebase.auth().currentUser) {
firebase.auth().currentUser.getIdToken(true)
.then((idToken) => {
client({
method: 'get',
url: '/',
headers: {
'AuthToken': idToken
}
}).then((res) => {
this.response = res.data.message
}).catch((error) => {
this.response = error
})
}).catch((error) => {
this.response = "Error getting auth token"
});
} else {
client({
method: 'get',
url: '/'
}).then((res) => {
this.response = res.data.message
}).catch((error) => {
this.response = error
})
}
},
signIn() {
firebase.auth()
.signInWithEmailAndPassword("[email protected]", "pass123!")
.then(() => {
this.authStatus = 'Authorized'
}).catch((err) => {
this.authStatus = err
})
},
signOut() {
firebase.auth().signOut().then(() => {
this.authStatus = 'Unauthorized'
}).catch((err) => {
this.authStatus = err
})
}
}
}
</script>
19 changes: 19 additions & 0 deletions client/src/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import Vue from 'vue'
import App from './App.vue'
import firebase from 'firebase'

firebase.initializeApp({
apiKey: "AIzaSyBqLUXaDvnDR2CoBvY94anzYi1P1o19DKs",
authDomain: "fbauthdemo-2a451.firebaseapp.com",
databaseURL: "https://fbauthdemo-2a451.firebaseio.com",
projectId: "fbauthdemo-2a451",
storageBucket: "",
messagingSenderId: "839675573680",
appId: "1:839675573680:web:b7e921f299469934659275"
})

Vue.config.productionTip = false

new Vue({
render: h => h(App),
}).$mount('#app')
45 changes: 45 additions & 0 deletions server/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
var express = require('express');
var path = require('path');
var cookieParser = require('cookie-parser');
var logger = require('morgan');
const cors = require('cors')
const admin = require('firebase-admin')

const serviceAccount = require("./config/fbServiceAccountKey.json");

admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
databaseURL: "https://fbauthdemo-2a451.firebaseio.com"
});

var app = express();

app.use(cors())
app.use(logger('dev'));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));

function checkAuth(req, res, next) {
if (req.headers.authtoken) {
admin.auth().verifyIdToken(req.headers.authtoken)
.then(() => {
next()
}).catch(() => {
res.status(403).send('Unauthorized')
});
} else {
res.status(403).send('Unauthorized')
}
}

app.use('/', checkAuth)

app.get('/', (req, res) => {
res.json({
message: 'Hello World!'
})
})

module.exports = app;
90 changes: 90 additions & 0 deletions server/bin/www
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#!/usr/bin/env node

/**
* Module dependencies.
*/

var app = require('../app');
var debug = require('debug')('server:server');
var http = require('http');

/**
* Get port from environment and store in Express.
*/

var port = normalizePort(process.env.PORT || '3000');
app.set('port', port);

/**
* Create HTTP server.
*/

var server = http.createServer(app);

/**
* Listen on provided port, on all network interfaces.
*/

server.listen(port);
server.on('error', onError);
server.on('listening', onListening);

/**
* Normalize a port into a number, string, or false.
*/

function normalizePort(val) {
var port = parseInt(val, 10);

if (isNaN(port)) {
// named pipe
return val;
}

if (port >= 0) {
// port number
return port;
}

return false;
}

/**
* Event listener for HTTP server "error" event.
*/

function onError(error) {
if (error.syscall !== 'listen') {
throw error;
}

var bind = typeof port === 'string'
? 'Pipe ' + port
: 'Port ' + port;

// handle specific listen errors with friendly messages
switch (error.code) {
case 'EACCES':
console.error(bind + ' requires elevated privileges');
process.exit(1);
break;
case 'EADDRINUSE':
console.error(bind + ' is already in use');
process.exit(1);
break;
default:
throw error;
}
}

/**
* Event listener for HTTP server "listening" event.
*/

function onListening() {
var addr = server.address();
var bind = typeof addr === 'string'
? 'pipe ' + addr
: 'port ' + addr.port;
debug('Listening on ' + bind);
}
12 changes: 12 additions & 0 deletions server/config/fbServiceAccountKey.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"type": "service_account",
"project_id": "fbauthdemo-2a451",
"private_key_id": "1d0ad38d6a57f46222213128da7a8c590d220676",
"private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCLs6kCKDSw32AK\ndaX0885NcPDyo2tzuTASGIBXNVQ3HzjXnYmjdQs3+c/FpTe6ZvpEJAc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YkB4TyGY/nYhmEetJ2uUioTotCGDuHOAqAkz6mWAHZ0l+OZ48m9KCASk3KMv5\n/sPJe7h+kL4cpm4NgK/o+bZtulXGlOdQd0plUYEv1HYOBCGk7FJyGMFBAoGBAJm9\nRFtj/G+EF4KmFZTqvdj+jlgzoxym2k8CW6MkLsCz/eqcqeoLwrFuKpwAXMK2yjZr\nPGjxk5N8SnJy8MkrCgzzoE1kMoVDPRbK3phRXTh3qZZKpQ9rALBktKkquTVTwrjr\ntkHJwHB7t2g7nZUOV1+G4mNQNYZJOv+Fc42c4lIBAoGAc8tdOcx8W0PFf+k+6BRX\nLiHc0ZRfOlYBJMYm4jEqzSlyiQck6Z280q+a1TpirHo5ZBTPtO5V/nbj101sVou0\nA2Y8EIfeahgP2Krd/JmYVfk8jyTmx+//ORTZgxcK5MYLzt5doXed7cuWb3aq+/tx\nF5WEVK3UiNpWhpgGFU4yOUg=\n-----END PRIVATE KEY-----\n",
"client_email": "[email protected]",
"client_id": "114972146474460792995",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-oqpvf%40fbauthdemo-2a451.iam.gserviceaccount.com"
}
Loading

0 comments on commit af5961c

Please sign in to comment.