mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Merge pull request #3519 from node-red/auto-login
Allow adminAuth to auto-login users when using passport strategy
This commit is contained in:
commit
646a786b75
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user