How do I add global policy to /auth/local route in Strapi 4?

How do I add global policy to /auth/local route in Strapi 4?

I tried this:

/src/extensions/users-permissions/routes/auth.js

‘use strict’;

module.exports = [
{
method: ‘POST’,
path: ‘/auth/local’,
handler: ‘auth.callback’,
config: {
policies: [‘global::is-human’],
middlewares: [‘plugin::users-permissions.rateLimit’],
prefix: ‘’,
},
},
];

/src/policies/is-human.js

“use strict”;
/**

  • isHuman policy.
    */

module.exports = async (policyContext, config, { strapi }) => {
console.log(“Is Human”, policyContext);
};

Please advise or correct me that what am I doing wrong.

Thanks

1 Like

Hey did you figure it out? Need same thing

1 Like