Current Record: before_authenticate #102

Return to Application Delegate Class The before_authenticate hook is a method that can be defined in the Application Delegate Class which i...

Current Record: before_authenticate #102

Return to Application Delegate Class The before_authenticate hook is a method that can be defined in the Application Delegate Class which i...

before_authenticate hook

[Permalink]

Return to Application Delegate Class

The before_authenticate hook is a method that can be defined in the Application Delegate Class which is called before the authentication step occurs on every request (not just on login). It is meant to be used to perform custom code that may affect the authentication settings.

Since

This hook has been available since Xataface Version 1.2.5.

Example

/**
 * Implemented trigger to be called before authentication to set the authentication
 * type to basic.
 */
function before_authenticate(){
    $auth = Dataface_AuthenticationTool::getInstance();
    if ( @$_SESSION['-login-type'] == 'basic' ) $auth->setAuthType('basic');
}

In the above example we used a separate action to store the user's preferred login type in a session variable. This preference is then applied in the before_authenticate method to override the authentication type.

Chain Authentication Support

The most common use of this hook is likely to implement some sort of chain authentication, where authentication methods are attempted until one succeeds.

See Also

blog comments powered by Disqus
Powered by Xataface
(c) 2005-2024 All rights reserved