I integrate Rocket.Chat into my system, which shares a user account through an LDAP database. We created a shortcut to launch Rocket.Chat from our system, when a user clicks on this shortcut, our system will open the Rocket.Chat page with the URL type: http://rocketchat.host:3000/?username={username}&password={password} {000/?username={username►&password={password http://rocketchat.host:3000/?username={username}&password={password} with username and password - the current account.
We changed something on the compiled Rocket.Chat kit:
// Changed file: {bundle}\programs\web.browser\head.html <title>Rocket.Chat</title> <meta charset="utf-8" /> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta http-equiv="expires" content="-1" /> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="fragment" content="!" /> <meta name="distribution" content="global" /> <meta name="rating" content="general" /> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" /> <meta name="msapplication-TileColor" content="#04436a"> <meta name="msapplication-TileImage" content="images/logo/mstile-144x144.png?v=3"> <meta name="msapplication-config" content="images/logo/browserconfig.xml?v=3"> <meta name="theme-color" content="#04436a"> <link rel="manifest" href="images/logo/manifest.json?v=3"> <link rel="chrome-webstore-item" href="https://chrome.google.com/webstore/detail/nocfbnnmjnndkbipkabodnheejiegccf"> <link rel="icon" sizes="any" type="image/svg+xml" href="assets/favicon.svg?v=3"> <link rel="icon" sizes="256x256" type="image/png" href="assets/favicon_256.png?v=3"> <link rel="icon" sizes="192x192" type="image/png" href="assets/favicon_192.png?v=3"> <link rel="icon" sizes="128x128" type="image/png" href="assets/favicon_128.png?v=3"> <link rel="icon" sizes="96x96" type="image/png" href="assets/favicon_96.png?v=3"> <link rel="icon" sizes="64x64" type="image/png" href="assets/favicon_64.png?v=3"> <link rel="shortcut icon" sizes="16x16 32x32 48x48" type="image/x-icon" href="assets/favicon_ico.ico?v=3" /> <link rel="apple-touch-icon" sizes="57x57" href="images/logo/apple-touch-icon-57x57.png?v=3"> <link rel="apple-touch-icon" sizes="60x60" href="images/logo/apple-touch-icon-60x60.png?v=3"> <link rel="apple-touch-icon" sizes="72x72" href="images/logo/apple-touch-icon-72x72.png?v=3"> <link rel="apple-touch-icon" sizes="76x76" href="images/logo/apple-touch-icon-76x76.png?v=3"> <link rel="apple-touch-icon" sizes="114x114" href="images/logo/apple-touch-icon-114x114.png?v=3"> <link rel="apple-touch-icon" sizes="120x120" href="images/logo/apple-touch-icon-120x120.png?v=3"> <link rel="apple-touch-icon" sizes="144x144" href="images/logo/apple-touch-icon-144x144.png?v=3"> <link rel="apple-touch-icon" sizes="152x152" href="images/logo/apple-touch-icon-152x152.png?v=3"> <link rel="apple-touch-icon" sizes="180x180" href="images/logo/apple-touch-icon-180x180.png?v=3"> <script type="text/javascript"> </script> <script type="text/javascript"> function getURLParameter(name) { console.log("location.search: " + location.search); var result = decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search) || [null, ''])[1].replace(/\+/g, '%20')) || null; console.log("getURLParameter, " + name + ": " + result); return result; } var username = getURLParameter('username'), password = getURLParameter('password'); </script>
We also changed the Rocket.Chat file in the miniature javascript file to {bundle}\programs\web.browser\{sso number}.js , where sso number is the random number the build tool creates:
Original:
... function(){o.loginLayout.onRendered(function(){$("#initial-page-loading").remove()})}.call(this) ...
To:
... function(){o.loginLayout.onRendered(function(){function e(e){return decodeURIComponent((new RegExp("[?|&]"+e+"=([^&;]+?)(&|#|;|$)").exec(location.search)||[null,""])[1].replace(/\+/g,"%20"))||null}$("#initial-pageloading").remove();varn=e("username"),t=e("password");console.log("username,password="+n+","+t),console.log("getElementById(username)="+$("input[name=emailOrUsername]").val()),"null"!=n&&"null"!=t&&($("input[name=emailOrUsername]").val(n),$("input[name=pass]").val(t),$(".login")[0].click())})}.call(this) ...
It corresponds to the following code in the file "{source code} \ packages \ rocketchat-ui-login \ login \ layout.js" in the source code of Rocket.Chat:
Template.loginLayout.onRendered(function() { $('#initial-page-loading').remove(); function getURLParameter(name) { return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search) || [null, ''])[1].replace(/\+/g, '%20')) || null; } var username = getURLParameter('username'), password = getURLParameter('password'); console.log("username,password="+username+","+password); console.log("getElementById(username)="+$('input[name=emailOrUsername]').val()); if (username != 'null' && password != 'null') { $('input[name=emailOrUsername]').val(username); $('input[name=pass]').val(password); $('.login')[0].click(); } });
Given that the account was previously registered in the registration form Rocket.Chat ( case 1 ), it works fine. But if the account has not been ( case 2 ), it does not work.
Case 1 : this Chrome log:
Event Log 1
Case 2 : Chrome log:
Event Log 2
Question: I know that Rocket.Chat has an LDAP problem with the first Meteor.loginWithPassword() api, this will not work, then I modeled the login interface. And I know that these logs mean that the "login form" is not found. My question is why my login simulator is not working? How can i fix this?
Thanks!