简体   繁体   English

Joomla 3.2如何编辑登录模块?

[英]Joomla 3.2 How to edit Login Module?

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. 我刚刚开始研究Joomla,我想做的是计算失败登录的次数,并在第5次失败登录后显示div或验证码。

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 所以我决定编辑现有的Login Module

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. 我确实还没有完全了解Joomla的想法,但是如果我以“野蛮”的方式进行此操作,则只需在其中插入查询以在<prefix>_users表下插入/更新特定列<prefix>_users每次失败的尝试。

Questions 问题

  1. Is this the right way of doing this or is there a more "Joomla" way of doing this? 这是正确的方法吗?还是有更多“ Joomla”方法?
  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) (我问是因为如果这样做,也许某些代码会因为缺少/新列等而停止工作)

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. 满足您需求的正确方法是Plugin,Joomla具有onUserLoginFailure默认插件事件。因此,您必须为您的需求创建一个User插件

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. 您还提到过要自定义#__users表永远不要这样做,因为它是Joomla核心表。一旦有可用的更新,它将删除您的列。 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. 因此,创建具有适当用户关系的新表,您可以在新表中使用user_id作为键,并在那里跟踪失败的尝试。

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. 因此,请使用标准的Joomla方法。

Refer Joomla default profile plugin for more details of plugin. 有关插件的更多详细信息,请参阅Joomla默认配置文件插件。

Hope it make sense.. 希望有道理..

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM