-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathldap_client.js
executable file
·47 lines (42 loc) · 1.16 KB
/
ldap_client.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
var firstAttempt = true;
Template.ldapLogin.events({
'click button[name="login"]': function(e, tpl) {
initLogin(e,tpl);
},
'keyup input' : function (e, tpl){
if (e.keyCode == 13){ //If Enter Key Pressed
initLogin(e,tpl);
}
},
'click button[name="logout"]': function(e) {
firstAttempt = true;
Meteor.logout();
}
});
Meteor.loginWithLdap = function (username, password, callback) {
Accounts.callLoginMethod({
methodArguments: [{username: username, password: password, ldap: true}],
validateResult: function (result) {
},
userCallback: callback
});
};
Template.ldapLogin.helpers({
failedLogin : function(){
return !firstAttempt; //return true if more than one attempt has been made. Show Error Message
}
});
// Initiate Login Process:
initLogin = function(e, tpl) {
var username = $(tpl.find('input[name="ldap"]')).val();
var password = $(tpl.find('input[name="password"]')).val();
var result = Meteor.loginWithLdap(username, password, function() {
if (Meteor.userId())
return true;
else {
firstAttempt = false;
return false;
}
});
return result;
};