The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/apps/meteor/server/lib/ldap/operations/fallback.ts

24 lines
588 B

import type { ILDAPEntry } from '@rocket.chat/core-typings';
import { getLdapDynamicValue } from '../getLdapDynamicValue';
export type LDAPVariableFallback = {
operation: 'fallback';
fallback: string;
minLength?: number;
};
export function executeFallback(ldapUser: ILDAPEntry, input: string, operation: LDAPVariableFallback): string | undefined {
let valid = Boolean(input);
if (valid && typeof operation.minLength === 'number') {
valid = input.length >= operation.minLength;
}
if (valid) {
return input;
}
return getLdapDynamicValue(ldapUser, operation.fallback);
}