Class LoginAssistantComponent

java.lang.Object
com.smartfoxserver.components.login.LoginAssistantComponent

public class LoginAssistantComponent extends Object

Overview

The Login Assistant component is a helper class that assist developers in creating a solid database-driven login system without the hassle of writing your own database access code.

In a nutshell this is how it works:

  1. Configure the DBManager in your application's Zone
  2. Instantiate the component in the init() method of your Extension
  3. Configure the component

Simple example of usage

Supposing we have a database table called muppets containing a name and pword fields we can use this code:
 public class MuppetsExtension extends SFSExtension
 {
        private LoginAssistantComponent lac;
        
        public void init()
        {
                lac = new LoginAssistantComponent(this);
                
                // Configure the component
                lac.getConfig().loginTable = "muppets";
                lac.getConfig().userNameField = "name";
                lac.getConfig().passwordField = "pword";
        }
        
        public void destroy()
        {
                lac.destroy();
        }
 }
 
NOTE: Always make sure to call the component's destroy() method inside your Extension's destroy() in order to release the component's resources.
See Also:
  • Constructor Details

    • LoginAssistantComponent

      public LoginAssistantComponent(ISFSExtension ext)
  • Method Details

    • destroy

      public void destroy()
      Releases the Component's resources.

      NOTE: Always make sure to call the component's destroy() method inside your Extension's destroy() in order to release the component's resources.

    • getConfig

      public LoginConfiguration getConfig()
      Obtain the configuration object that allows to setup all the parameters of the Login process.
      Returns:
      the LoginAssistant's current configuration