You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on May 14, 2024. It is now read-only.
const ldapLogin = async (
request: Request,
response: Response,
next: NextFunction
) => {
const { email, password } = request.body;
const userDN = uid=${email},${ldapConfig.userBaseDN};
const SearchOptions: SearchOptions = {
filter: uid=${email},
scope: "sub",
attributes: ["cn", "sn", "uid"],
};
try {
const { searchEntries } = await client.search(
ldapConfig.userBaseDN,
SearchOptions
);
await client.bind(userDN, password);
const token = generateToken(email);
const authResponse = constructAuthResponse(searchEntries[0], token);
response.send(authResponse);
} catch (error) {
if (error instanceof InvalidCredentialsError) {
return next(
new errors.ValidationError(
[
{
message: INVALID_CREDENTIALS_ERROR.MESSAGE,
code: INVALID_CREDENTIALS_ERROR.CODE,
param: INVALID_CREDENTIALS_ERROR.PARAM,
},
],
INVALID_CREDENTIALS_ERROR.MESSAGE
)
);
} else if (error instanceof NoSuchObjectError) {
return next(
new errors.NotFoundError(
USER_NOT_FOUND_ERROR.MESSAGE,
USER_NOT_FOUND_ERROR.CODE,
USER_NOT_FOUND_ERROR.PARAM
)
);
} else {
console.error(error);
response.status(500).send("Internal Server Error");
}
}
}; Here is the code of my login controller for ldap auth. I get array with data of the user for the first time only and for every subsequent search after the first I get [] as the response.
The text was updated successfully, but these errors were encountered:
Please provide a minimal reproducible example (MRE). Doing so will help us diagnose your issue. It should be the bare minimum code needed to trigger the issue, and easily runnable without any changes or extra code. Please review the integration tests, e.g. issue-940.test.js, for examples of good MREs.
You may use a GitHub repository to host the code if it is too much to fit in a code block (or two).
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
const ldapLogin = async (
request: Request,
response: Response,
next: NextFunction
) => {
const { email, password } = request.body;
const userDN =
uid=${email},${ldapConfig.userBaseDN}
;const SearchOptions: SearchOptions = {
filter:
uid=${email}
,scope: "sub",
attributes: ["cn", "sn", "uid"],
};
try {
const { searchEntries } = await client.search(
ldapConfig.userBaseDN,
SearchOptions
);
await client.bind(userDN, password);
const token = generateToken(email);
const authResponse = constructAuthResponse(searchEntries[0], token);
response.send(authResponse);
} catch (error) {
if (error instanceof InvalidCredentialsError) {
return next(
new errors.ValidationError(
[
{
message: INVALID_CREDENTIALS_ERROR.MESSAGE,
code: INVALID_CREDENTIALS_ERROR.CODE,
param: INVALID_CREDENTIALS_ERROR.PARAM,
},
],
INVALID_CREDENTIALS_ERROR.MESSAGE
)
);
} else if (error instanceof NoSuchObjectError) {
return next(
new errors.NotFoundError(
USER_NOT_FOUND_ERROR.MESSAGE,
USER_NOT_FOUND_ERROR.CODE,
USER_NOT_FOUND_ERROR.PARAM
)
);
} else {
console.error(error);
response.status(500).send("Internal Server Error");
}
}
}; Here is the code of my login controller for ldap auth. I get array with data of the user for the first time only and for every subsequent search after the first I get [] as the response.
The text was updated successfully, but these errors were encountered: