yaml-admin-api 0.0.112 → 0.0.113

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yaml-admin-api",
3
- "version": "0.0.112",
3
+ "version": "0.0.113",
4
4
  "license": "MIT",
5
5
  "description": "YAML Admin API package",
6
6
  "type": "commonjs",
package/src/login/auth.js CHANGED
@@ -3,7 +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, master_email, master_password } = config;
6
+ const { db, jwt_secret, passwordEncoding, master_email, master_password, expires } = config;
7
7
  const comparePassword = async (plainPass, hashword) => {
8
8
  if(passwordEncoding === 'bcrypt') {
9
9
  let isPasswordMatch = await bcrypt.compare(plainPass, hashword)
@@ -44,6 +44,7 @@ const withConfig = (config) => {
44
44
  if (err) res.json({ r: false, msg: '알 수 없는 이유로 토큰 생성에 실패하였습니다.' });
45
45
 
46
46
  req.token = token;
47
+ req.expires = (expires && expires > 0) ? expires : null;
47
48
  delete user.password;
48
49
  req.user = user;
49
50
  next();
@@ -1,16 +1,17 @@
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
5
  passwordEncoding: yml.login["password-encoding"],
6
6
  master_email: yml.login["master-email"],
7
- master_password: yml.login["master-password"]
7
+ master_password: yml.login["master-password"],
8
+ expires: yml.login["expires"]
8
9
  });
9
10
 
10
11
  app.get(api_prefix + '/member/login',
11
12
  auth.authenticate,
12
13
  function (req, res) {
13
- res.json({ r: true, token: req.token, member: req.user });
14
+ res.json({ r: true, token: req.token, expires: req.expires, member: req.user });
14
15
  }
15
16
  );
16
17
 
@@ -24,7 +25,7 @@ module.exports = async function (app, db, yml, api_prefix) {
24
25
  app.post(api_prefix + '/member/login',
25
26
  auth.authenticate,
26
27
  function (req, res) {
27
- res.json({ r: true, token: req.token, member: req.user });
28
+ res.json({ r: true, token: req.token, expires: req.expires, member: req.user });
28
29
  }
29
30
  );
30
31