yaml-admin-api 0.0.59 → 0.0.60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/login/auth.js +3 -4
- package/src/member/member.js +5 -1
package/package.json
CHANGED
package/src/login/auth.js
CHANGED
|
@@ -3,8 +3,7 @@ const jwt = require('jsonwebtoken');
|
|
|
3
3
|
const crypto = require('crypto');
|
|
4
4
|
|
|
5
5
|
const withConfig = (config) => {
|
|
6
|
-
const { db, jwt_secret, passwordEncoding } = config;
|
|
7
|
-
|
|
6
|
+
const { db, jwt_secret, passwordEncoding, master_email, master_password } = config;
|
|
8
7
|
const comparePassword = async (plainPass, hashword) => {
|
|
9
8
|
if(passwordEncoding === 'bcrypt') {
|
|
10
9
|
let isPasswordMatch = await bcrypt.compare(plainPass, hashword)
|
|
@@ -73,9 +72,9 @@ const withConfig = (config) => {
|
|
|
73
72
|
const email = req.query.email || req.body.email;
|
|
74
73
|
const password = req.query.pass || req.body.pass;
|
|
75
74
|
const type = req.query.type || req.body.type || "email";
|
|
76
|
-
if (email ===
|
|
75
|
+
if (master_email && master_password && email === master_email && password === master_password) {
|
|
77
76
|
authenticateSuccess(req, res,
|
|
78
|
-
{ id: '1111111', email: '
|
|
77
|
+
{ id: '1111111', email: 'master', name: 'master', type: 'email' },
|
|
79
78
|
next);
|
|
80
79
|
}
|
|
81
80
|
else {
|
package/src/member/member.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
const {withConfig} = require('../login/auth.js');
|
|
2
2
|
|
|
3
3
|
module.exports = async function (app, db, yml, api_prefix) {
|
|
4
|
-
const auth = withConfig({ db, jwt_secret: yml.login["jwt-secret"],
|
|
4
|
+
const auth = withConfig({ db, jwt_secret: yml.login["jwt-secret"],
|
|
5
|
+
passwordEncoding: yml.login["password-encoding"],
|
|
6
|
+
master_email: yml.login["master-email"],
|
|
7
|
+
master_password: yml.login["master-password"]
|
|
8
|
+
});
|
|
5
9
|
|
|
6
10
|
app.get(api_prefix + '/member/login',
|
|
7
11
|
auth.authenticate,
|