fix: Parameters missing in afterFind trigger of authentication adapters (#8458)
This commit is contained in:
@@ -214,7 +214,7 @@ module.exports = function (authOptions = {}, enableAnonymousUsers = true) {
|
||||
return { validator: authDataValidator(provider, adapter, appIds, providerOptions), adapter };
|
||||
};
|
||||
|
||||
const runAfterFind = async authData => {
|
||||
const runAfterFind = async (req, authData) => {
|
||||
if (!authData) {
|
||||
return;
|
||||
}
|
||||
@@ -230,7 +230,12 @@ module.exports = function (authOptions = {}, enableAnonymousUsers = true) {
|
||||
providerOptions,
|
||||
} = authAdapter;
|
||||
if (afterFind && typeof afterFind === 'function') {
|
||||
const result = afterFind(authData[provider], providerOptions);
|
||||
const requestObject = {
|
||||
ip: req.config.ip,
|
||||
user: req.auth.user,
|
||||
master: req.auth.isMaster,
|
||||
};
|
||||
const result = afterFind(requestObject, authData[provider], providerOptions);
|
||||
if (result) {
|
||||
authData[provider] = result;
|
||||
}
|
||||
|
||||
@@ -850,7 +850,12 @@ RestQuery.prototype.handleAuthAdapters = async function () {
|
||||
return;
|
||||
}
|
||||
await Promise.all(
|
||||
this.response.results.map(result => this.config.authDataManager.runAfterFind(result.authData))
|
||||
this.response.results.map(result =>
|
||||
this.config.authDataManager.runAfterFind(
|
||||
{ config: this.config, auth: this.auth },
|
||||
result.authData
|
||||
)
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -292,7 +292,7 @@ export class UsersRouter extends ClassesRouter {
|
||||
if (authDataResponse) {
|
||||
user.authDataResponse = authDataResponse;
|
||||
}
|
||||
await req.config.authDataManager.runAfterFind(user.authData);
|
||||
await req.config.authDataManager.runAfterFind(req, user.authData);
|
||||
|
||||
return { response: user };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user