/** * Copyright 2014, 2015 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. **/ RED.user = (function() { function login(opts,done) { if (typeof opts == 'function') { done = opts; opts = {}; } var dialog = $('
'+ '
'+ '
'+ '
'+ '
'+ '
'); dialog.dialog({ autoOpen: false, dialogClass: "ui-dialog-no-close", modal: true, closeOnEscape: false, width: 600, resizable: false, draggable: false }); $("#node-dialog-login-fields").empty(); $.ajax({ dataType: "json", url: "auth/login", success: function(data) { if (data.type == "credentials") { var i=0; for (;i",{class:"form-row"}); $('
').appendTo(row); $('').appendTo(row); row.appendTo("#node-dialog-login-fields"); } $('
Login failed'+ (opts.cancelable?'Cancel':'')+ 'Login
').appendTo("#node-dialog-login-fields"); $("#node-dialog-login-submit").button().click(function( event ) { $("#node-dialog-login-submit").button("option","disabled",true); $("#node-dialog-login-failed").hide(); $(".login-spinner").show(); var body = { client_id: "node-red-editor", grant_type: "password", scope:"*" } for (var i=0;i"+RED.settings.user.username+"" }); RED.menu.addItem("btn-usermenu",{ id:"btn-logout", label:"Logout", onselect: function() { RED.user.logout(); } }); } } function init() { if (RED.settings.user) { $('
  • ') .prependTo(".header-toolbar"); RED.menu.init({id:"btn-usermenu", options: [] }); updateUserMenu(); } } return { init: init, login: login, logout: logout } })();