[fix] Authorization Token name in header

This commit is contained in:
alban 2020-05-18 01:13:20 +02:00
parent db9c25363a
commit c9b7f9f024

View File

@ -2,16 +2,17 @@
* *
* *
2020-05-15T20:28:14.357Z 2020-05-15T20:28:14.357Z
PUT /changelog curl -X PUT 'http://localhost:9200/changelog' -d '
{ {
"mappings": { "mappings": {
"properties": { "properties": {
"author": { "type": "keyword" }, "author": { "type": "keyword" },
"content": { "type": "text" }, "content": { "type": "text" },
"created_at": { "type": "date","format": "basic_date_time" } "created_at": { "type": "date","format": "date_optional_time" }
}
} }
} }
}' -H "Content-Type: application/json"
* *
*/ */
@ -24,7 +25,7 @@ const authorizationToken = process.env.AUTH_TOKEN || "hello";
const port = process.env.APP_PORT || 3000; const port = process.env.APP_PORT || 3000;
function requireAuthentication( req, res, next ){ function requireAuthentication( req, res, next ){
const userAuth = req.get("authorizationToken") || req.query.authorizationToken; const userAuth = req.get("AuthorizationToken") || req.query.authorizationToken;
console.log( "userAuth : "+userAuth) console.log( "userAuth : "+userAuth)
if( userAuth && userAuth === authorizationToken ) next(); if( userAuth && userAuth === authorizationToken ) next();
else res.end("Auth required"); else res.end("Auth required");