Auto login Rocket.Chat with LDAP - autologin

I am integrating Rocket.Chat into my system that share user account through LDAP database. We created a shortcut to go Rocket.Chat from our system, when user click to this shortcut, our system will open Rocket.Chat page with url type: http://rocketchat.host:3000/?username={username}&password={password} with username and password is current account.
We changed something on compiled bundle of Rocket.Chat:
// 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">
// alert("test js");
</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'); // Query parameter from url that our system passed
Meteor.loginWithPassword(username, password, function () {
console.log('loginWithPassword callback, username: ' + username + "; password:" + password);
}); // Call login direct to Meteor.login
// Query "username" and "password" input fields from login from then pass data and simulate click login button
document.addEventListener("DOMContentLoaded", function(event) {
document.getElementById('username').value = username;
document.getElementById('password').value = password;
document.getElementById('loginButton').click();
});
</script>
We also changed in minified javascript file of Rocket.Chat at {bundle}\programs\web.browser\{sso number}.js where sso number is randomize number that build tool generate :
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 at file "{source code}\packages\rocketchat-ui-login\login\layout.js" on Rocket.Chat source code:
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();
}
});
With account has been previously logged in by Rocket.Chat login form (case 1), it work ok. But if account hasn't been yet (case 2), it fail.
Case 1 : This Chrome log:
Case 1 log
Case 2 : Chrome log:
Case 2 log
I know Rocket.Chat has issue with LDAP is with first login by Meteor.loginWithPassword() api, it won't work then I simulated login UI. And I know these logs mean "login form" wasn't found. My question is why my login UI simulation not work? How can I fix it?

Related

Having Whatsapp sharing url problem in Next js , i.e OpenGraph, Not showing or fetching data in whatsapp when using dynamic data

When I am using meta og tags in _app.js its work with static content,
but when I use it on other pages like index , its not showing anything in whatsapp sharing
_app.js
<Head>
<meta name="viewport" content="initial-scale=1, width=device-width" />
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
<meta name="viewport" content="user-scalable=no" />
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"
/>
<meta name="HandheldFriendly" content="true" />
<meta property="og:title" content="The Rock" />
<meta property="og:type" content="video.movie" />
<meta property="og:url" content={"https://connectme.co.in"} />
<meta property="og:image" content={"https://images.wsj.net/im-515021?width=860&height=573"} />
</Head>
its working here but in index page
its not working
index.js
<Head>
<meta property="og:title" content={profileData?.name} />
<meta property="og:image" content={profileData?.profileimg} />
<meta property="og:type" content="profile.image" />
<meta property="og:url" content={"https://connectme.co.in/"} />
</Head>
profileData is ny dynamic data
now its not working here ,
when i Checked in facebook debugger its showing this
Inferred Property
The 'og:image' property should be explicitly provided, even if a value can be inferred from other tags.

EJS/Node/Express - Having a header partial, how to change title for each page?

I recently took a course on back-end web developing.
As the title says, I don't get how can I use a header partial for the whole website but have different titles for each page. (because is included in the tag)
Is there any trick?
1st) In your Express route:
app.get("/", function(req, res){
res.locals.title = "Abel's Home Page"; // THIS LINE IS KEY
res.render("home.ejs");
});
2nd) In your views/home.ejs file:
<% include partials/header.ejs %>
3rd) In your views/partials/header.ejs file:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title><%= title %></title> <!-- THIS LINE IS KEY -->
<link rel="stylesheet" href="../style.css">
<link rel="shortcut icon" href="../logo_sm.png" type="image/x-icon">
</head>
<body>
Each page that includes the partial is free to pass data to said partial through parameters. See here for an example.

google search doesn't show correct title and description

Please search google for amirkabir data miners
Check Title and Description for https://adm-co.net
As you can see in page source, google show Amirkabir Data Miners: داده کاوان امیرکبیر instead of داده کاوان امیرکبیر | Amirkabir Data Miners and completely wrong description.
I registered site in Google Webmaster Tools, and Google Analytics and tried anything.
What do i have to do!?
<title>داده کاوان امیرکبیر | Amirkabir Data Miners</title>
<meta charset="utf-8" />
<link rel="apple-touch-icon" sizes="57x57" href="/Content/images/favicons/apple-touch-icon-57x57.png">
<link rel="apple-touch-icon" sizes="114x114" href="/Content/images/favicons/apple-touch-icon-114x114.png">
<link rel="apple-touch-icon" sizes="72x72" href="/Content/images/favicons/apple-touch-icon-72x72.png">
<link rel="apple-touch-icon" sizes="144x144" href="/Content/images/favicons/apple-touch-icon-144x144.png">
<link rel="apple-touch-icon" sizes="60x60" href="/Content/images/favicons/apple-touch-icon-60x60.png">
<link rel="apple-touch-icon" sizes="120x120" href="/Content/images/favicons/apple-touch-icon-120x120.png">
<link rel="apple-touch-icon" sizes="76x76" href="/Content/images/favicons/apple-touch-icon-76x76.png">
<link rel="apple-touch-icon" sizes="152x152" href="/Content/images/favicons/apple-touch-icon-152x152.png">
<link rel="apple-touch-icon" sizes="180x180" href="/Content/images/favicons/apple-touch-icon-180x180.png">
<link rel="icon" type="image/png" href="/Content/images/favicons/favicon-192x192.png" sizes="192x192">
<link rel="icon" type="image/png" href="/Content/images/favicons/favicon-160x160.png" sizes="160x160">
<link rel="icon" type="image/png" href="/Content/images/favicons/favicon-96x96.png" sizes="96x96">
<link rel="icon" type="image/png" href="/Content/images/favicons/favicon-16x16.png" sizes="16x16">
<link rel="icon" type="image/png" href="/Content/images/favicons/favicon-32x32.png" sizes="32x32">
<meta name="msapplication-TileColor" content="#e3e3e3">
<meta name="msapplication-TileImage" content="/mstile-144x144.png">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0' name='viewport' />
<meta name="description" content="شرکت داده کاوان امیرکبیر | تولید کننده نرم افزارهای تحت وب، از قبیل حسابداری آنلاین 'کاج سیستم' ، سیستم مدیریت پروژه 'تسک من' و ...">
<meta name="keywords" content="شرکت داده کاوان امیرکبیر,شرکت,داده,کاوان,امیرکبیر,حسابداری, سیستم های تحت وب, برنامه نویسی,حسابداری آنلاین,سیستم های تحت وب, طراحی نرم افزار, adm, amikabir, data, miners, amirkabir data miners, adm (amirkabir data miners), programming, financial, taskman, taskmanager, web application, web, application">
<meta name="language" content="fa">
<meta name="robots" content="all" />
<meta name="rights" content="Copyright © 2015 ADM-CO - All rights reserved">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
Many are getting similar kind of issues, Before Google has automatically set the Meta description when it is not presented in the site. It sets the description as per the search query and based on the content in the website.
Now the Google does the same for the Meta Title and Meta Description even though it is presented in the website.

Rendering wrong head with login layout

Can anyone tell me how it is possibile that the following layout in a Rails 4 app
# app/views/layout/login.html.erb
<!DOCTYPE html>
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<title>PIPPO</title>
<meta content="yes" name="apple-mobile-web-app-capable">
<meta content="black-translucent" name="apple-mobile-web-app-status-bar-style">
<meta name="viewport" content="initial-scale = 1.0,maximum-scale = 1.0" />
<link href="/assets/login.css" media="all" rel="stylesheet" />
<script src="/assets/login.js"></script>
<%= csrf_meta_tags %>
</head>
<body>
<div class="main-content">
<%= yield %>
</div>
</body>
</html>
With the following controller
class SessionsController < ApplicationController
layout 'login'
...
def destroy
Session.find(session[:id]).close
reset_session
respond_to do |format|
flash[:success] = t('sessions.logout')
format.html { redirect_to login_url }
end
end
end
and routes
...
get 'login', to: 'sessions#new', as: 'login'
get 'logout', to: 'sessions#destroy', as: 'logout'
...
produces the following HTML once I click on <%= link_to 'logout', logout_path %>?
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<title>PIPPO</title>
<meta content="yes" name="apple-mobile-web-app-capable">
<meta content="black-translucent" name="apple-mobile-web-app-status-bar-style">
<meta name="viewport" content="initial-scale = 1.0,maximum-scale = 1.0" />
<link href="/assets/application.css" media="all" rel="stylesheet" />
<script src="/assets/application.js"></script>
<meta content="authenticity_token" name="csrf-param" />
<meta content="l9+umk+wjpXY4UFiKEeuQkGgMvjbbZ2uDxyJHowTJFo=" name="csrf-token" />
</head>
Am I missing anything here? It is two days I'm trying to figure this out.
Why is it using the head from the main layout instead of the one in login?
Thanks for your help.
UPDATE - Forgot to mention my log file states:
Rendered sessions/new.html.erb within layouts/login (1.4ms)
As per the layout name given in the question, i.e.,
app/views/layout.login.html.erb
There are couple of things wrong here:
layouts should be placed in app/views/layouts folder
File name should be login.html.erb and not layout.login.html.erb
In your case, Rails could not find login.html.erb in app/views/layouts, it rendered the default layout app/views/layouts/application.html.erb.

Zombie.js browser not returning full html?

I'm trying to figure out Zombie.js.
I have this script:
var Browser = require("zombie");
var assert = require("assert");
Browser.visit("http://web.mit.edu", function (e,browser) {
console.log(browser.html());
});
That just visits the page and logs the html, but I'm getting html that doesn't match what the source file I get in a normal browser.
Zombie.js output:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>MIT - Massachusetts Institute of Technology</title>
<meta name="keywords" content="Massachusetts Institute of Technology, MIT" />
<meta name="description" content="MIT is devoted to the advancement of knowledge and education of students in areas that contribute to or prosper in an environment of science and technology." />
<meta name="robots" content="index,follow,noodp,noydir" />
<meta name="allow-search" content="yes" />
<meta name="language" content="en" />
<meta name="distribution" content="global" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="Expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="cache-control" content="no-store" />
<link rel="canonical" href="http://web.mit.edu" />
<link rel="image_src" href="http://web.mit.edu/img/MIT_logo.gif" />
<link rel="search" type="application/opensearchdescription+xml" href="http://web.mit.edu/opensearch.xml" title="MIT - Massachusetts Institute of Technology" />
<link href="https://plus.google.com/104984516469461796485/" rel="publisher" />
<!-- icons -->
<link rel="shortcut icon" href="/favicon.ico" />
<!-- rss -->
<link rel="alternate" type="application/rss+xml" title="MIT - Home Page News" href="http://feeds.feedburner.com/mit/news-homepage" />
<!-- style sheets - global -->
<link href="styles/style3536.css" rel="stylesheet" type="text/css" media="all" />
<script src="http://dnn506yrbagrg.cloudfront.net/pages/scripts/0011/6778.js" type="text/javascript"></script>
<script type="text/javascript" src="http://www.google-analytics.com/ga.js"></script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(
['_setAccount', 'UA-1592615-11'],
['_trackPageview','/'],
['rollup._setAccount', 'UA-31439876-1'],
['rollup._trackPageview', '/mit/www/']
);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<style type="text/css" media="screen">#flashcontent {visibility:hidden}#flashcontent {visibility:visible}</style>
</head>
<body>
Tuesday, October 23, 2012
</body>
</html>
And the real source is really long, check it out at http://web.mit.edu
What's going on?
If you use assert to compare the source code to zombie's result you'll get an error because of the following points:
First of all browser.html() doesn't give you the doctype.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Second and more important MIT uses javascript files which are loaded after a one second timeout
<script type="text/javascript">
setTimeout(function(){var a=document.createElement("script");
var b=document.getElementsByTagName('script')[0];
a.src=document.location.protocol+"//dnn506yrbagrg.cloudfront.net/pages/scripts/0011/6778.js";
a.async=true;a.type="text/javascript";b.parentNode.insertBefore(a,b)}, 1);
</script>
or asynchronously
var _gaq = _gaq || [];
_gaq.push(
['_setAccount', 'UA-1592615-11'],
['_trackPageview','/'],
['rollup._setAccount', 'UA-31439876-1'],
['rollup._trackPageview', '/mit/www/']
);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
The source code shows you the code to load them whereas zombie gives you the results
<script src="http://dnn506yrbagrg.cloudfront.net/pages/scripts/0011/6778.js" type="text/javascript"></script>
and
<script type="text/javascript" src="http://www.google-analytics.com/ga.js"></script>
Depending on the content of those scripts they might further change the DOM and zombie shows even more deviations. Unfortunately I'm not aware of a workaround.

Resources