Jump to content

Developer Documentation

4.2 and below: Login Handlers

  1. Introduction to Login Handlers

    IPS Community Suite comes with a number of different methods to allow users to log in to the community, called "login handlers". Generally speaking, there are two types of login handlers: "Standard" login handlers which take a username and/or email address and password. For example, the default login handler, LDAP and IPS Connect. Login handlers which use a custom form, which are usually (though not necessarily) OAuth based. For example, Facebook, Twitter and LinkedIn login.  
  2. Creating standard login handlers

    Basic skeleton Here is a basic skeleton for a standard login handler: namespace IPS\Login; class _Example extends LoginAbstract { /** * @brief Authentication types */ public $authTypes = \IPS\Login::AUTH_TYPE_USERNAME; /** * Authenticate * * @param array $values Values from from * @return \IPS\Member * @throws \IPS\Login\Exception */ public function authenticate( $values ) { /* Init */ $username = $values['auth']; // Depending on the value of $authTypes this
  3. Creating other login handlers (such as OAuth)

    Basic skeleton Here is a basic skeleton for an OAuth-based login handler: namespace IPS\Login; class _Example extends LoginAbstract { /** * @brief Icon */ public static $icon = 'lock'; /** * Get Form * * @param \IPS\Http\Url $url The URL for the login page * @param bool $ucp If this is being done from the User CP * @return string */ public function loginForm( $url, $ucp=FALSE ) { $redirectUrl = \IPS\Http\Url::internal( 'applications/core/interface/example/au
  4. Adding AdminCP settings for login handlers

    You will likely need to create settings for your login handler so when an admin sets it up they can provide keys, etc. There are two methods to assist with this.  acpForm() can return an array of form fields allowing you to specify these settings, and testSettings() allows you to check the settings are correct. For example, to define a client ID setting you might do something like this: /** * ACP Settings Form * * @param string $url URL to redirect user to after successful submission
  5. Merging accounts in a login handler

    With some login handlers, particularly those which are OAuth-based, you may need to merge accounts. For example, imagine a user is registered on your community, and then they try to log in using Facebook. In this situation, you don't want to create a new account, but rather prompt the user to link their Facebook account with their existing account. In this case, throw an exception in your authenticate() method: $exception = new \IPS\Login\Exception( 'generic_error', \IPS\Login\Exception::MER
  6. Checking for username/email address availability in login handlers

    When a user registers an account on the community, your handler can check if the email address or username is acceptable. This is useful if you want your login handler to provide close integration such as is provided by the LDAP and IPS Connect handlers. The methods are emailIsInUse() and usernameIsInUse().   boolean emailIsInUse( string $email [, \IPS\Member $exclude=NULL ] ) $email (string, required) The email address to check $exclude (\IPS\Member, optional) If pro
  7. Other callbacks available to login handlers

    Handling account changes When a user changes their email, password or username on the community, your handler can be notified of these changes and update their databases. You need to implement the canChange() method to let the User CP controllers know you support this functionality, then implement the methods changeEmail(), changePassword() and changeUsername() as appropriate.   boolean canChange( string $type, \IPS\Member $member ) Indicates whether this login handler will su
×
×
  • Create New...