I'm using NPM ldapjs and this Meteor LDAP project to try to enable LDAP on my test Telescope website. The main issue is that I want LDAP to be the sole method of logging in. My plan is to have a wrapper around the built-in Telescope (Meteor?) login method. If the LDAP credentials pass, it runs the Telescope login script and continues as normal.
Perhaps this is a hacky solution and a better one exists? In any case, I need LDAP to work. Right now, I'm trying to overwrite the default login method with this:
Template.signin.events({
'submit': function(event, template){
Session.set('errorMessage', null);
event.preventDefault();
console.log("My login script ran!"); // I never see this message =(
return Meteor.loginWithLDAP(template.find('#login-username').value,
template.find('#login-password').value, function(error) {
return Session.set('errorMessage', 'Login failed');
});
}
});
As the comment says, the log command never runs (I know because I'm using Chrome, and the console after attempting to log in is blank), and additionally, I get this with every page load:
Uncaught TypeError: Cannot read property 'events' of undefined
(anonymous function) @ ldap_client.js:45
(anonymous function) @ typ_accounts-ldap.js?0ad074ecfc292bededc7d318da4746392aa0f5f8:94
(anonymous function) @ typ_accounts-ldap.js?0ad074ecfc292bededc7d318da4746392aa0f5f8:101
Line 45 is Template.signin.events({, so I have concluded that Template does not have a signin member. I've seen that Template.signin.events({...}) code a few different places (just google "Template.signin.events" with the quotes), but I guess they took that stuff out with a Meteor update?
Another version I have tried is
Template.loginButtons.events({
'submit #login-form': function(event, template){
...blah blah blah...
but *gasp* that doesn't work either. It does NOT give me the Uncaught TypeError that I get with the original code, but I guess it just fails to overwrite the correct handler.
Just to be clear, this is all code that runs client-side within a custom package of mine. My JS file is a direct child of the custom package I have in Telescope.
How do I overwrite the default login handler in Meteor? (i.e. how do I make my code run when you click the "log in" button instead of Meteor's code?)
Update:
Upon request, I have tried the steps in this short walkthrough that shows an example of "Extending Meteor Accounts". I get lots of errors in the console on the client side, and one error in the console on the server side. I get the feeling that is happening because the suggestion is one that doesn't play well with Telescope specifically, but perhaps if I had a plain old instance of Meteor, it would work.