Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to create user authentication plugin in joomla

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 339
    Comment on it

    Authentication plugin provides facility for user to authenticate the user from any source such as database. As all the plugins in Joomla are inherited by jPlugin class so we can create our own custom plugin which will inherit from base class for using basic functionality that is required. In order to create authentication plugin the child class name must begin with plgAuthentication and end must be the custom name which user has provided to that plugin. here i am creating a name as userauth so the name of class will become plgAuthenticationuserauth. inside the class we need to define onAuthenticate() function which will call once the system use this plugin to authenticate the user.

    This function will require credentials,option and response as a parameter So inside this function we can perform the authentication checking that is necessary for your plugin for eg. username exist ,invalid username password,user name,password does not match etc depends upon user requirement. Note file name must be the name of the plugin which you have created. In this case file name will become userauth.php. So basically for making custom authentication plugin we need two files first is custom plugin class and second is XML file to install that plugin.

    <?php
    
    class plgAuthenticationUserauth extends JPlugin
    {
    
        function onUserAuthenticate( $credentials, $options, &$response )
        {
    
           //authentication checks  and conditions here
        }
    }
    ?>
    

    Also we need to create basic XML file to install this plugin in joomla and also need to note that group attribute in XML file have value authentication which denotes that this plugin act as an authentication plugin.

    <?xml version="1.0" encoding="utf-8"?>
    <extension version="3.1" type="plugin" group="authentication">
        <name>Authentication - UserAuth</name>
        <author></author>
        <creationDate></creationDate>
        <copyright></copyright>
        <license></license>
        <authorEmail></authorEmail>
        <authorUrl></authorUrl>
        <version>1.0</version>
        <description>simple custom authentication plugin</description>
        <files>
            <filename plugin="userauth">userauth.php</filename>
        </files>
        <config/>
    </extension>
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: