Replace slugify with limax and fix sync operations

This commit is contained in:
Harry Adel 2026-01-29 21:01:39 +02:00
parent 7d56dca80b
commit fb79ccaa55
4 changed files with 10 additions and 5 deletions

View file

@ -12,7 +12,6 @@ Package.describe({
Package.onUse(function(api) { Package.onUse(function(api) {
api.use('yasaricli:slugify');
api.use('ecmascript'); api.use('ecmascript');
api.use('underscore'); api.use('underscore');
api.use('sha'); api.use('sha');
@ -25,3 +24,8 @@ Package.onUse(function(api) {
api.mainModule('server/index.js', 'server'); api.mainModule('server/index.js', 'server');
}); });
Npm.depends({
'ldapjs': '2.3.3',
'limax': '4.1.0'
});

View file

@ -203,7 +203,7 @@ Accounts.registerLoginHandler('ldap', async function(loginRequest) {
await syncUserData(user, ldapUser); await syncUserData(user, ldapUser);
if (LDAP.settings_get('LDAP_LOGIN_FALLBACK') === true) { if (LDAP.settings_get('LDAP_LOGIN_FALLBACK') === true) {
Accounts.setPassword(user._id, loginRequest.ldapPass, {logout: false}); await Accounts.setPasswordAsync(user._id, loginRequest.ldapPass, {logout: false});
} }
return { return {

View file

@ -1,5 +1,6 @@
import _ from 'underscore'; import _ from 'underscore';
import { SyncedCron } from 'meteor/quave:synced-cron'; import { SyncedCron } from 'meteor/quave:synced-cron';
import limax from 'limax';
import LDAP from './ldap'; import LDAP from './ldap';
import { log_debug, log_info, log_warn, log_error } from './logger'; import { log_debug, log_info, log_warn, log_error } from './logger';
@ -20,7 +21,7 @@ export function slug(text) {
if (LDAP.settings_get('LDAP_UTF8_NAMES_SLUGIFY') !== true) { if (LDAP.settings_get('LDAP_UTF8_NAMES_SLUGIFY') !== true) {
return text; return text;
} }
text = slugify(text, '.'); text = limax(text, { separator: '.' });
return text.replace(/[^0-9a-z-_.]/g, ''); return text.replace(/[^0-9a-z-_.]/g, '');
} }
@ -307,7 +308,7 @@ export async function addLdapUser(ldapUser, username, password) {
try { try {
// This creates the account with password service // This creates the account with password service
userObject.ldap = true; userObject.ldap = true;
userObject._id = Accounts.createUser(userObject); userObject._id = await Accounts.createUserAsync(userObject);
// Add the services.ldap identifiers // Add the services.ldap identifiers
await Meteor.users.updateAsync({ _id: userObject._id }, { await Meteor.users.updateAsync({ _id: userObject._id }, {

View file

@ -12,7 +12,7 @@ Meteor.methods({
// throw new Meteor.Error('error-not-authorized', 'Not authorized', { method: 'ldap_test_connection' }); // throw new Meteor.Error('error-not-authorized', 'Not authorized', { method: 'ldap_test_connection' });
//} //}
if (LDAP.settings_get(LDAP_ENABLE) !== true) { if (LDAP.settings_get('LDAP_ENABLE') !== true) {
throw new Meteor.Error('LDAP_disabled'); throw new Meteor.Error('LDAP_disabled');
} }