Actions

API15

Difference between revisions of "JAuthentication/authenticate"

From Joomla! Documentation

< API15:JAuthentication
(New page: ===Description=== Finds out if a set of login credentials are valid by asking all obvserving objects to run their respective authentication routines. <span class="editsection" style="fo...)
 
m (removing red link to edit, no existant pages)
 
Line 3: Line 3:
  
 
<span class="editsection" style="font-size:76%;">
 
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[Description:JAuthentication/authenticate|Edit Descripton]]<nowiki>]</nowiki>
+
<nowiki>[<! removed edit link to red link >]</nowiki>
 
</span>
 
</span>
  
{{Description:JAuthentication/authenticate}}
+
<! removed transcluded page call, red link never existed >
  
 
===Syntax===
 
===Syntax===
Line 90: Line 90:
  
 
<span class="editsection" style="font-size:76%;">
 
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[SeeAlso:JAuthentication/authenticate|Edit See Also]]<nowiki>]</nowiki>
+
<nowiki>[<! removed edit link to red link >]</nowiki>
 
</span>
 
</span>
{{SeeAlso:JAuthentication/authenticate}}
+
<! removed transcluded page call, red link never existed >
  
 
===Examples===
 
===Examples===
Line 105: Line 105:
 
  format= ,,,
 
  format= ,,,
 
</dpl>
 
</dpl>
 +
[[Category:Archived pages API15]]

Latest revision as of 07:43, 12 May 2013

Replacement filing cabinet.png
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.

Contents

Description

Finds out if a set of login credentials are valid by asking all obvserving objects to run their respective authentication routines.

[<! removed edit link to red link >]

<! removed transcluded page call, red link never existed >

Syntax

authenticate($credentials, $options)
Parameter Name Default Value Description
$credentials Array holding the user credentials
$options

Returns

mixed Integer userid for valid user if credentials are valid or boolean false if they are not

Defined in

libraries/joomla/user/authentication.php

Importing

jimport( 'joomla.user.authentication' );

Source Body

function authenticate($credentials, $options)
{
        // Initialize variables
        $auth = false;
 
        // Get plugins
        $plugins = JPluginHelper::getPlugin('authentication');
 
        // Create authencication response
        $response = new JAuthenticationResponse();
 
        /*
         * Loop through the plugins and check of the creditials can be used to authenticate
         * the user
         *
         * Any errors raised in the plugin should be returned via the JAuthenticationResponse
         * and handled appropriately.
         */
        foreach ($plugins as $plugin)
        {
                $className = 'plg'.$plugin->type.$plugin->name;
                if (class_exists( $className )) {
                        $plugin = new $className($this, (array)$plugin);
                }
 
                // Try to authenticate
                $plugin->onAuthenticate($credentials, $options, $response);
 
                // If authentication is successfull break out of the loop
                if($response->status === JAUTHENTICATE_STATUS_SUCCESS)
                {
                        if (empty( $response->type )) {
                                $response->type = isset( $plugin->_name ) ? $plugin->_name : $plugin->name;
                        }
                        if (empty( $response->username )) {
                                $response->username = $credentials['username'];
                        }
 
                        if (empty( $response->fullname )) {
                                $response->fullname = $credentials['username'];
                        }
 
                        if (empty( $response->password )) {
                                $response->password = $credentials['password'];
                        }
 
                        break;
                }
        }
        return $response;
}

[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >

Examples

<CodeExamplesForm />