mirror of
https://github.com/samsonjs/mit-license.git
synced 2026-03-25 09:25:49 +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')
|
||||
|
||||
module.exports = async (request, response, next) => {
|
||||
response.locals.id = request.hostname.split('.')[0]
|
||||
const id = request.hostname.split('.')[0]
|
||||
|
||||
if (request.method.toUpperCase() !== 'GET') {
|
||||
return next()
|
||||
|
|
@ -16,7 +16,7 @@ module.exports = async (request, response, next) => {
|
|||
try {
|
||||
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 }) {
|
||||
if (code !== 'ENOENT') {
|
||||
|
|
|
|||
Loading…
Reference in a new issue