Преглед на файлове

Try to fix [LDAP Login: "Login forbidden", ReferenceError: req is not defined](https://github.com/wekan/wekan-ldap/issues/44).
Please test.

Thanks to xet7 !

Closes wekan/wekan-ldap#44

Lauri Ojansivu преди 6 години
родител
ревизия
32f6de1eec
променени са 2 файла, в които са добавени 15 реда и са изтрити 5 реда
  1. 5 5
      client/components/main/layouts.js
  2. 10 0
      server/header-login.js

+ 5 - 5
client/components/main/layouts.js

@@ -105,10 +105,10 @@ async function authentication(event, instance) {
   // If header login id is set, use it for login.
   // If header login id is set, use it for login.
   // Header username = Email address
   // Header username = Email address
   // Header password = Login ID
   // Header password = Login ID
-  // Not user currently: req.headers[process.env.HEADER_LOGIN_FIRSTNAME]
-  //                and  req.headers[process.env.HEADER_LOGIN_LASTNAME]
-  const match = req.headers[process.env.HEADER_LOGIN_EMAIL] || $('#at-field-username_and_email').val();
-  const password = req.headers[process.env.HEADER_LOGIN_ID] || $('#at-field-password').val();
+  // Not user currently: request.headers[Meteor.settings.public.headerLoginFirstname]
+  //                and  request.headers[Meteor.settings.public.headerLoginLastname]
+  const match = request.headers[Meteor.settings.public.headerLoginEmail] || $('#at-field-username_and_email').val();
+  const password = request.headers[Meteor.settings.public.headerLoginId] || $('#at-field-password').val();
 
 
   if (!match || !password) return;
   if (!match || !password) return;
 
 
@@ -117,7 +117,7 @@ async function authentication(event, instance) {
   if (result === 'password') return;
   if (result === 'password') return;
 
 
   // If header login id is not set, don't try to login automatically.
   // If header login id is not set, don't try to login automatically.
-  if (!process.env.HEADER_LOGIN_ID) {
+  if (!Meteor.settings.public.headerLoginId) {
     // Stop submit #at-pwd-form
     // Stop submit #at-pwd-form
     event.preventDefault();
     event.preventDefault();
     event.stopImmediatePropagation();
     event.stopImmediatePropagation();

+ 10 - 0
server/header-login.js

@@ -0,0 +1,10 @@
+Meteor.startup(() => {
+
+  if ( process.env.HEADER_LOGIN_ID ) {
+    Meteor.settings.public.headerLoginId = process.env.HEADER_LOGIN_ID;
+    Meteor.settings.public.headerLoginEmail = process.env.HEADER_LOGIN_EMAIL;
+    Meteor.settings.public.headerLoginFirstname = process.env.HEADER_LOGIN_FIRSTNAME;
+    Meteor.settings.public.headerLoginLastname = process.env.HEADER_LOGIN_LASTNAME;
+  }
+
+});