Hi,
I want to create a custom login route instead of /api/auth/local
.
Reason for this is that I want to check if a specific IP tried to login more than 3 times in 10 minutes for safety reasons. After the third time I want to block this IP for 15 minutes so basically I want to do some extra checks. Also creating a middleware for the login process would be nice. I have created a custom route and a controller. I can’t get it work. This is my code in my controller right now:
async login(ctx) {
try {
const { identifier, password } = ctx.request.body;
const ip = ctx.request.ip;
const authenticatedUser = strapi.plugins['users-permissions'].services.auth.login({
identifier,
password,
});
return ctx.send({ user: authenticatedUser });
} catch (error) {
return ctx.send({ error: 'Authentication failed' }, 401);
}
},
Hope someone knows a little bit more about this