Question

Requirement

I just starting studying Joomla and what I want to do is to count the number of failed logins and show a div or a captcha after the 5th failed login.

What I tried

I first tried to find extensions that will fit the requirement (without me coding anything) but unfortunately, all the extensions seem to do something else (like send email on failed attempt, etc).

So I decided to edit the existing Login Module anso here I am at

class UsersControllerUser extends UsersController
{
    public function login()
    {
       //the code here
    }
}

I really don't a have a full grasp of the idea of Joomla yet but If I were to do this the "barbaric" way, I would just insert there a query to insert/update a certain column under <prefix>_users table on every failed attempt.

Questions

  1. Is this the right way of doing this or is there a more "Joomla" way of doing this?
  2. If I were to do this, is it ok to just manually add a column in the above table? (I'm asking because if I'd do that, maybe some code will stop working because of missing/new columns etc)
Was it helpful?

Solution

Try this,

The proper method for your requirement is Plugin, Joomla have default plugin event for onUserLoginFailure .So you have to create a User plugin for your requirement.

Also you mentioned you are customizing #__users table Never do that bcoz its a Joomla core table Once an update available it will remove your column. So create new table with proper user relation, you can use user_id as key in your new table and track the failed attempt there.

You can create your custom table with part of your plugin the just an install of plugin will create the table too. So Please go for standard Joomla methods.

Refer Joomla default profile plugin for more details of plugin.

Hope it make sense..

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top