mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Support custom login message and button
This commit is contained in:
parent
7a3741165b
commit
b7e96ce6bc
@ -126,6 +126,14 @@ async function login(req,res) {
|
|||||||
if (themeContext.login && themeContext.login.image) {
|
if (themeContext.login && themeContext.login.image) {
|
||||||
response.image = themeContext.login.image;
|
response.image = themeContext.login.image;
|
||||||
}
|
}
|
||||||
|
if (themeContext.login?.message) {
|
||||||
|
response.loginMessage = themeContext.login?.message
|
||||||
|
}
|
||||||
|
if (themeContext.login?.button) {
|
||||||
|
response.prompts = [
|
||||||
|
{ type: "button", ...themeContext.login.button }
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
res.json(response);
|
res.json(response);
|
||||||
}
|
}
|
||||||
|
@ -206,14 +206,28 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (theme.login) {
|
if (theme.login) {
|
||||||
|
let themeContextLogin = {}
|
||||||
|
let hasLoginTheme = false
|
||||||
if (theme.login.image) {
|
if (theme.login.image) {
|
||||||
url = serveFile(themeApp,"/login/",theme.login.image);
|
url = serveFile(themeApp,"/login/",theme.login.image);
|
||||||
if (url) {
|
if (url) {
|
||||||
themeContext.login = {
|
themeContextLogin.login = {
|
||||||
image: url
|
image: url
|
||||||
}
|
}
|
||||||
|
hasLoginTheme = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (theme.login.message) {
|
||||||
|
themeContextLogin.message = theme.login.message
|
||||||
|
hasLoginTheme = true
|
||||||
|
}
|
||||||
|
if (theme.login.button) {
|
||||||
|
themeContextLogin.button = theme.login.button
|
||||||
|
hasLoginTheme = true
|
||||||
|
}
|
||||||
|
if (hasLoginTheme) {
|
||||||
|
themeContext.login = themeContextLogin
|
||||||
|
}
|
||||||
}
|
}
|
||||||
themeApp.get("/", async function(req,res) {
|
themeApp.get("/", async function(req,res) {
|
||||||
const themePluginList = await runtimeAPI.plugins.getPluginsByType({type:"node-red-theme"});
|
const themePluginList = await runtimeAPI.plugins.getPluginsByType({type:"node-red-theme"});
|
||||||
|
@ -168,6 +168,37 @@ RED.user = (function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
if (data.prompts) {
|
||||||
|
if (data.loginMessage) {
|
||||||
|
const sessionMessages = $("<div/>",{class:"form-row",style:"text-align: center"}).appendTo("#node-dialog-login-fields");
|
||||||
|
$('<div>').text(data.loginMessage).appendTo(sessionMessages);
|
||||||
|
}
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
for (;i<data.prompts.length;i++) {
|
||||||
|
var field = data.prompts[i];
|
||||||
|
var row = $("<div/>",{class:"form-row",style:"text-align: center"}).appendTo("#node-dialog-login-fields");
|
||||||
|
var loginButton = $('<a href="#" class="red-ui-button"></a>',{style: "padding: 10px"}).appendTo(row).on("click", function() {
|
||||||
|
document.location = field.url;
|
||||||
|
});
|
||||||
|
if (field.image) {
|
||||||
|
$("<img>",{src:field.image}).appendTo(loginButton);
|
||||||
|
} else if (field.label) {
|
||||||
|
var label = $('<span></span>').text(field.label);
|
||||||
|
if (field.icon) {
|
||||||
|
$('<i></i>',{class: "fa fa-2x "+field.icon, style:"vertical-align: middle"}).appendTo(loginButton);
|
||||||
|
label.css({
|
||||||
|
"verticalAlign":"middle",
|
||||||
|
"marginLeft":"8px"
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
label.appendTo(loginButton);
|
||||||
|
}
|
||||||
|
loginButton.button();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (opts.cancelable) {
|
if (opts.cancelable) {
|
||||||
$("#node-dialog-login-cancel").button().on("click", function( event ) {
|
$("#node-dialog-login-cancel").button().on("click", function( event ) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user