Explorar o código

Merge pull request #933 from weseek/fix/814-registration-doesnt-work-when-basic-auth-enabled

Fix/814 registration doesnt work when basic auth enabled
Yuki Takei %!s(int64=7) %!d(string=hai) anos
pai
achega
da2bdf1184
Modificáronse 2 ficheiros con 5 adicións e 2 borrados
  1. 1 0
      CHANGES.md
  2. 4 2
      src/server/routes/login.js

+ 1 - 0
CHANGES.md

@@ -4,6 +4,7 @@
 
 
 * Improvement: Show display name when mouse hover to user image
 * Improvement: Show display name when mouse hover to user image
 * Fix: URL in slack message is broken on Safari
 * Fix: URL in slack message is broken on Safari
+* Fix: Registration does not work when basic auth is enabled
 
 
 ## 3.4.5
 ## 3.4.5
 
 

+ 4 - 2
src/server/routes/login.js

@@ -139,8 +139,10 @@ module.exports = function(crowi, app) {
   actions.register = function(req, res) {
   actions.register = function(req, res) {
     const googleAuth = require('../util/googleAuth')(crowi);
     const googleAuth = require('../util/googleAuth')(crowi);
 
 
-    // ログイン済みならさようなら
-    if (req.user) {
+    // redirect to '/' if both of these are true:
+    //  1. user has logged in
+    //  2. req.user is not username/email string (which is set by basic-auth-connect)
+    if (req.user != null && req.user instanceof Object) {
       return res.redirect('/');
       return res.redirect('/');
     }
     }