mirror of
https://github.com/samsonjs/mit-license.git
synced 2026-04-27 15:07:42 +00:00
Update load-user.js
This commit is contained in:
parent
d69042ac23
commit
6e1d0a6f4c
1 changed files with 2 additions and 2 deletions
|
|
@ -2,7 +2,7 @@ const path = require('path')
|
||||||
const loadJsonFile = require('load-json-file')
|
const loadJsonFile = require('load-json-file')
|
||||||
|
|
||||||
module.exports = async (request, response, next) => {
|
module.exports = async (request, response, next) => {
|
||||||
response.locals.id = request.hostname.split('.')[0]
|
const id = request.hostname.split('.')[0]
|
||||||
|
|
||||||
if (request.method.toUpperCase() !== 'GET') {
|
if (request.method.toUpperCase() !== 'GET') {
|
||||||
return next()
|
return next()
|
||||||
|
|
@ -16,7 +16,7 @@ module.exports = async (request, response, next) => {
|
||||||
try {
|
try {
|
||||||
response.locals.user = {
|
response.locals.user = {
|
||||||
...response.locals.user,
|
...response.locals.user,
|
||||||
...await loadJsonFile(path.join(__dirname, '..', 'users', `${response.locals.id}.json`))
|
...await loadJsonFile(path.join(__dirname, '..', 'users', `${id}.json`))
|
||||||
}
|
}
|
||||||
} catch ({ code, message }) {
|
} catch ({ code, message }) {
|
||||||
if (code !== 'ENOENT') {
|
if (code !== 'ENOENT') {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue