Wt: Wt::Auth::Login Class Reference

Wt 4.10.4

Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
Wt::Auth::Login Class Reference

A class that manages the current login state. More...

`#include <Wt/Auth/Login.h>`

Inheritance diagram for Wt::Auth::Login:
[legend]

## Public Types
typedef LoginState | State
| Typedef for enum Wt::Auth::LoginState.
Public Types inherited from Wt::WObject
typedef void(WObject::*) | Method()
| Typedef for a WObject method without arguments.

## Public Member Functions
| Login ()
| Default constructor.
void | login (const User &user, LoginState state=LoginState::Strong)
| Logs a user in.
void | logout ()
| Logs the current user out.
LoginState | state () const
| Returns the current login state.
bool | loggedIn () const
| Returns whether a user has successfully logged in.
const User & | user () const
| Returns the user currently identified.
Signal & | changed ()
| Signal that indicates login changes.
Public Member Functions inherited from Wt::WObject
void | addChild (std::unique_ptr< WObject > child)
| Add a child WObject whose lifetime is determined by this WObject.
template<typename Child >
Child * | addChild (std::unique_ptr< Child > child)
| Add a child WObject, returning a raw pointer.
std::unique_ptr< WObject > | removeChild (WObject *child)
| Remove a child WObject, so its lifetime is no longer determined by this WObject.
template<typename Child >
std::unique_ptr< Child > | removeChild (Child *child)
| Remove a child WObject, so its lifetime is no longer determined by this WObject.
virtual const std::string | id () const
| Returns the (unique) identifier for this object.
virtual void | setObjectName (const std::string &name)
| Sets an object name.
virtual std::string | objectName () const
| Returns the object name.
void | resetLearnedSlots ()
| Resets learned stateless slot implementations.
template<class T >
void | resetLearnedSlot (void(T::*method)())
| Resets a learned stateless slot implementation.
template<class T >
WStatelessSlot * | implementStateless (void(T::*method)())
| Declares a slot to be stateless and learn client-side behaviour on first invocation.
template<class T >
WStatelessSlot * | implementStateless (void(T::*method)(), void(T::*undoMethod)())
| Declares a slot to be stateless and learn client-side behaviour in advance.
void | isNotStateless ()
| Marks the current function as not stateless.
template<class T >
WStatelessSlot * | implementJavaScript (void(T::*method)(), const std::string &jsCode)
| Provides a JavaScript implementation for a method.
Public Member Functions inherited from Wt::Core::observable
| observable () noexcept
| Default constructor.
virtual | ~observable ()
| Destructor.
template<typename... Args, typename C >
auto | bindSafe (void(C::*method)(Args...)) noexcept
| Protects a method call against object destruction.
template<typename... Args, typename C >
auto | bindSafe (void(C::*method)(Args...) const) const noexcept
| Protects a const method call against object destruction.
template<typename Function >
auto | bindSafe (const Function &function) noexcept
| Protects a function against object destruction.

## Additional Inherited Members
Static Public Member Functions inherited from Wt::WObject
Protected Member Functions inherited from Wt::WObject
virtual WStatelessSlot * | getStateless (Method method)
| On-demand stateless slot implementation.

## Detailed Description

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

## Constructor & Destructor Documentation

## ◆ Login()

Wt::Auth::Login::Login | ( |  | ) |

Default constructor.

Creates a login object in the LoginState::LoggedOut state.

## Member Function Documentation

## ◆ changed()

Signal & Wt::Auth::Login::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 loggedIn() as the user may have been identified correctly but have a LoginState::Disabled state() for example.

## ◆ loggedIn()

bool Wt::Auth::Login::loggedIn | ( |  | ) | const

Returns whether a user has successfully logged in.

This returns `true` only if the state is LoginState::Weak or LoginState::Strong.

See also
  state()

## ◆ login()

void Wt::Auth::Login::login | ( | const User & | user,
|  | LoginState | state = LoginState::Strong )

Logs a user in.

A user can be logged in using either a LoginState::Disabled, LoginState::Weak or LoginState::Strong `state`. The login state is forced to LoginState::Disabled if User::status() returns Disabled.

See also
  logout(), loggedIn()

## ◆ logout()

void Wt::Auth::Login::logout | ( |  | ) |

Logs the current user out.

Sets the state to LoginState::LoggedOut.

## ◆ state()

LoginState Wt::Auth::Login::state | ( |  | ) | const

Returns the current login state.

See also
  login(), logout()

## ◆ user()

const User & Wt::Auth::Login::user | ( |  | ) | const

Returns the user currently identified.

Returns the user currently identified.

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