浏览代码

fix 24, support getting api-key from header

isayme 7 年之前
父节点
当前提交
7cf63a3f3d
共有 1 个文件被更改,包括 6 次插入1 次删除
  1. 6 1
      server/passport.js

+ 6 - 1
server/passport.js

@@ -46,8 +46,13 @@ passport.use(
   })
 );
 
+const localAPIKeyOptions = {
+  apiKeyField: 'apikey',
+  apiKeyHeader: 'x-api-key',
+};
+
 passport.use(
-  new LocalAPIKeyStrategy(async (apikey, done) => {
+  new LocalAPIKeyStrategy(localAPIKeyOptions, async (apikey, done) => {
     try {
       const user = await getUser({ apikey });
       if (!user) {