mirror of
				https://github.com/node-red/node-red.git
				synced 2025-03-01 10:36:34 +00:00 
			
		
		
		
	Allow adminAuth to auto-login users when using passport strategy
Fixes #3467
This commit is contained in:
		| @@ -106,9 +106,15 @@ async function login(req,res) { | ||||
|                 urlPrefix += "/"; | ||||
|             } | ||||
|             response = { | ||||
|                 "type":"strategy", | ||||
|                 "prompts":[{type:"button",label:mergedAdminAuth.strategy.label, url: urlPrefix + "auth/strategy"}] | ||||
|                 "type":"strategy" | ||||
|             } | ||||
|             if (mergedAdminAuth.strategy.autoLogin) { | ||||
|                 response.autoLogin = true | ||||
|                 response.loginRedirect = urlPrefix + "auth/strategy" | ||||
|             } | ||||
|             response.prompts = [ | ||||
|                 {type:"button",label:mergedAdminAuth.strategy.label, url: urlPrefix + "auth/strategy"} | ||||
|             ] | ||||
|             if (mergedAdminAuth.strategy.icon) { | ||||
|                 response.prompts[0].icon = mergedAdminAuth.strategy.icon; | ||||
|             } | ||||
|   | ||||
| @@ -118,20 +118,26 @@ RED.user = (function() { | ||||
|                     }); | ||||
|  | ||||
|                 } else if (data.type == "strategy") { | ||||
|                     var sessionMessage = /[?&]session_message=(.*?)(?:$|&)/.exec(window.location.search); | ||||
|                     RED.sessionMessages = RED.sessionMessages || []; | ||||
|                     if (sessionMessage) { | ||||
|                         RED.sessionMessages.push(decodeURIComponent(sessionMessage[1])); | ||||
|                         if (history.pushState) { | ||||
|                             var newurl = window.location.protocol+"//"+window.location.host+window.location.pathname | ||||
|                             window.history.replaceState({ path: newurl }, "", newurl); | ||||
|                         } else { | ||||
|                             window.location.search = ""; | ||||
|                         } | ||||
|                     } | ||||
|  | ||||
|                     if (RED.sessionMessages.length === 0 && data.autoLogin) { | ||||
|                         document.location = data.loginRedirect | ||||
|                         return | ||||
|                     } | ||||
|  | ||||
|                     i = 0; | ||||
|                     for (;i<data.prompts.length;i++) { | ||||
|                         var field = data.prompts[i]; | ||||
|                         var sessionMessage = /[?&]session_message=(.*?)(?:$|&)/.exec(window.location.search); | ||||
|                         if (sessionMessage) { | ||||
|                             RED.sessionMessages = RED.sessionMessages || []; | ||||
|                             RED.sessionMessages.push(sessionMessage[1]); | ||||
|                             if (history.pushState) { | ||||
|                                 var newurl = window.location.protocol+"//"+window.location.host+window.location.pathname | ||||
|                                 window.history.replaceState({ path: newurl }, "", newurl); | ||||
|                             } else { | ||||
|                                 window.location.search = ""; | ||||
|                             } | ||||
|                         } | ||||
|                         if (RED.sessionMessages) { | ||||
|                             var sessionMessages = $("<div/>",{class:"form-row",style:"text-align: center"}).appendTo("#node-dialog-login-fields"); | ||||
|                             RED.sessionMessages.forEach(function (msg) { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user