Class Login

java.lang.Object
eu.webtoolkit.jwt.WObject
eu.webtoolkit.jwt.auth.Login

public class Login
extends WObject
A class that manages the current login state.

This is a model class which is typically associated with a single session, for the duration of the session.

Widgets that implement authentication (and thus produce authentication changes), will indicate their result in this object using the login() or logout() methods.

Widgets that want to react to login state changes (typically, as user logging in or out) should listen to the changed() signal of this object.

See Also:
AuthWidget
  • Nested Class Summary

    Nested classes/interfaces inherited from class eu.webtoolkit.jwt.WObject

    WObject.FormData
  • Constructor Summary

    Constructors
    Constructor Description
    Login()
    Default constructor.
  • Method Summary

    Modifier and Type Method Description
    Signal changed()
    Signal that indicates login changes.
    LoginState getState()
    Returns the current login state.
    User getUser()
    Returns the user currently identified.
    boolean isLoggedIn()
    Returns whether a user has successfully logged in.
    void login​(User user)
    Logs a user in.
    void login​(User user, LoginState state)
    Logs a user in.
    void logout()
    Logs the current user out.

    Methods inherited from class eu.webtoolkit.jwt.WObject

    addChild, getId, getObjectName, remove, setFormData, setObjectName, tr

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Login

      public Login()
      Default constructor.

      Creates a login object in the LoggedOut state.

  • Method Details

    • login

      public void login​(User user, LoginState state)
      Logs a user in.

      A user can be logged in using either a DisabledLogin, WeakLogin or StrongLogin state . The login state is forced to DisabledLogin if User.getStatus() returns Disabled.

      See Also:
      logout(), isLoggedIn()
    • login

      public final void login​(User user)
    • logout

      public void logout()
      Logs the current user out.

      Sets the state to LoggedOut.

    • getState

      public LoginState getState()
      Returns the current login state.

      See Also:
      login(User user, LoginState state), logout()
    • isLoggedIn

      public boolean isLoggedIn()
      Returns whether a user has successfully logged in.

      This returns true only if the state is WeakLogin or StrongLogin.

      See Also:
      getState()
    • getUser

      public User getUser()
      Returns the user currently identified.

      Returns the user currently identified.

      Note: This may also be a user whose account is currently disabled.

    • changed

      public Signal changed()
      Signal that indicates login changes.

      This signal is emitted as a result of login() or logout(). If no user was logged in, then a changed() signal does not necessarily mean that user is isLoggedIn() as the user may have been identified correctly but have a DisabledLogin getState() for example.