This repository has been archived by the owner on Dec 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
795 additions
and
388 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const fs = require('fs') | ||
const { Router } = require('express') | ||
var bodyParser = require('body-parser') | ||
const jwt = require('jsonwebtoken') | ||
const authConfig = require('../../auth.config.js') | ||
|
||
const router = Router() | ||
|
||
router.use(bodyParser.urlencoded({ extended: false })); | ||
router.use(bodyParser.json()) | ||
|
||
router.post('/auth/login', function (req, res, next) { | ||
if (req.body.name === authConfig.default[0].user && req.body.password === authConfig.default[0].pass) { | ||
const token = jwt.sign({ sub: authConfig.default[0].user }, authConfig.default[0].jwtKey, { expiresIn: '7d' }); | ||
res.json(token) | ||
} else | ||
res.json('false') | ||
}) | ||
|
||
module.exports = router | ||
|
||
|
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
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
Empty file.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import fs from 'fs' | ||
import crypto from 'crypto' | ||
|
||
console.log('Create account!') | ||
|
||
const stream = fs.createWriteStream('./auth.config.js'); | ||
let r = crypto.randomBytes(20).toString('hex'); | ||
stream.write("export default [{ user: 'cosmos', pass: 'cosmos', jwtKey: '" + r + "' } ]"); |
Oops, something went wrong.