This file contains 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 Vue from 'vue' | |
import VueRouter from 'vue-router' | |
Vue.use(VueRouter) | |
import LoginComponent from './components/LoginComponent' | |
import HomeComponent from './components/HomeComponent' | |
import LogoutComponent from './components/LogoutComponent' | |
import store from './store' |
This file contains 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
declare module "*.json" { | |
const value: any; | |
export default value; | |
} |
This file contains 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 express = require("express"); | |
const bodyParser = require("body-parser"); | |
const cors = require("cors"); | |
const app = express(); | |
// CORS multiple Domain | |
var allowlist = [ | |
'http://localhost:3000', | |
'http://localhost:4200', |
This file contains 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 { authJwt } = require("../middleware"); | |
const controller = require("../controllers/user.controller"); | |
module.exports = function(app) { | |
app.use(function(req, res, next) { | |
res.header( | |
"Access-Control-Allow-Headers", | |
"x-access-token, Origin, Content-Type, Accept" | |
); | |
next(); |
This file contains 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 { verifyRegister } = require("../middleware"); | |
const controller = require("../controllers/auth.controller"); | |
module.exports = function(app) { | |
app.use(function(req, res, next) { | |
res.header( | |
"Access-Control-Allow-Headers", | |
"x-access-token, Origin, Content-Type, Accept" | |
); | |
next(); |
This file contains 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 authJwt = require("./authJwt"); | |
const verifyRegister = require("./verifyRegister"); | |
module.exports = { | |
authJwt, | |
verifyRegister | |
}; |
This file contains 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 jwt = require("jsonwebtoken"); | |
const config = require("../config/auth.config.js"); | |
const db = require("../models"); | |
const User = db.user; | |
verifyToken = (req, res, next) => { | |
let token = req.headers["x-access-token"]; | |
if (!token) { | |
return res.status(403).send({ |
This file contains 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 db = require("../models"); | |
const User = db.user; | |
checkDuplicateUsernameOrEmail = (req, res, next) => { | |
// Username | |
User.findOne({ | |
where: { | |
username: req.body.username | |
} | |
}).then(user => { |
This file contains 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
exports.allAccess = (req, res) => { | |
res.status(200).send("Authentication with JSON Web Token (JWT)"); | |
}; |
This file contains 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 db = require("../models"); | |
const config = require("../config/auth.config"); | |
const User = db.user; | |
var jwt = require("jsonwebtoken"); | |
var bcrypt = require("bcryptjs"); | |
exports.register = (req, res) => { | |
// Save User to Database | |
User.create({ |
NewerOlder