diff options
author | Lauri Ojansivu <x@xet7.org> | 2019-04-20 15:18:33 +0300 |
---|---|---|
committer | Lauri Ojansivu <x@xet7.org> | 2019-04-20 15:18:33 +0300 |
commit | 73e265d8fd050ae3daa67472b4465a5c49d68910 (patch) | |
tree | 677b233934a43d8f873e24c794ce289d85e3a9b7 /packages/wekan-ldap/client | |
parent | 6117097a93bfb11c8bd4c87a23c44a50e22ceb87 (diff) | |
download | wekan-73e265d8fd050ae3daa67472b4465a5c49d68910.tar.gz wekan-73e265d8fd050ae3daa67472b4465a5c49d68910.tar.bz2 wekan-73e265d8fd050ae3daa67472b4465a5c49d68910.zip |
Include to Wekan packages directory contents, so that meteor command would build all directly.
This also simplifies build scripts.
Thanks to xet7 !
Diffstat (limited to 'packages/wekan-ldap/client')
-rw-r--r-- | packages/wekan-ldap/client/loginHelper.js | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/packages/wekan-ldap/client/loginHelper.js b/packages/wekan-ldap/client/loginHelper.js new file mode 100644 index 00000000..48a290c1 --- /dev/null +++ b/packages/wekan-ldap/client/loginHelper.js @@ -0,0 +1,52 @@ +// Pass in username, password as normal +// customLdapOptions should be passed in if you want to override LDAP_DEFAULTS +// on any particular call (if you have multiple ldap servers you'd like to connect to) +// You'll likely want to set the dn value here {dn: "..."} +Meteor.loginWithLDAP = function(username, password, customLdapOptions, callback) { + // Retrieve arguments as array + const args = []; + for (let i = 0; i < arguments.length; i++) { + args.push(arguments[i]); + } + // Pull username and password + username = args.shift(); + password = args.shift(); + + // Check if last argument is a function + // if it is, pop it off and set callback to it + if (typeof args[args.length-1] === 'function') { + callback = args.pop(); + } else { + callback = null; + } + + // if args still holds options item, grab it + if (args.length > 0) { + customLdapOptions = args.shift(); + } else { + customLdapOptions = {}; + } + + // Set up loginRequest object + const loginRequest = { + ldap: true, + username, + ldapPass: password, + ldapOptions: customLdapOptions, + }; + + Accounts.callLoginMethod({ + // Call login method with ldap = true + // This will hook into our login handler for ldap + methodArguments: [loginRequest], + userCallback(error/*, result*/) { + if (error) { + if (callback) { + callback(error); + } + } else if (callback) { + callback(); + } + }, + }); +}; |