Wt  3.3.2
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Groups Pages
Public Types | Public Member Functions | List of all members
Wt::Auth::User Class Reference

A user. More...

#include <Wt/Auth/User>

Public Types

enum  Status { Disabled, Normal }
 Enumeration for a user's account status. More...
 
enum  EmailTokenRole { VerifyEmail, LostPassword }
 Enumeration for an email token stored for the user. More...
 

Public Member Functions

 User ()
 Default constructor. More...
 
 User (const std::string &id, const AbstractUserDatabase &database)
 Constructor. More...
 
AbstractUserDatabasedatabase () const
 Returns the user database. More...
 
bool operator== (const User &other) const
 Comparison operator. More...
 
bool operator!= (const User &other) const
 Comparison operator. More...
 
bool isValid () const
 Returns whether the user is valid. More...
 
const std::string & id () const
 Returns the user id. More...
 
WString identity (const std::string &provider) const
 Returns an identity.
 
void addIdentity (const std::string &provider, const WString &identity)
 Adds an identity. More...
 
void setIdentity (const std::string &provider, const WString &identity)
 Sets an identity. More...
 
void removeIdentity (const std::string &provider)
 Removes an identity. More...
 
void setPassword (const PasswordHash &password) const
 Sets a password. More...
 
PasswordHash password () const
 Returns the password. More...
 
void setEmail (const std::string &address) const
 Sets the email address. More...
 
std::string email () const
 Returns the email address. More...
 
void setUnverifiedEmail (const std::string &address) const
 Sets the unverified email address. More...
 
std::string unverifiedEmail () const
 Returns the unverified email address. More...
 
Status status () const
 Returns the account status. More...
 
Token emailToken () const
 Returns the email token. More...
 
EmailTokenRole emailTokenRole () const
 Returns the email token role. More...
 
void setEmailToken (const Token &token, EmailTokenRole role) const
 Sets an email token. More...
 
void clearEmailToken () const
 Clears the email token. More...
 
void addAuthToken (const Token &token) const
 Adds an authentication token. More...
 
void removeAuthToken (const std::string &hash) const
 Removes an authentication token. More...
 
int updateAuthToken (const std::string &hash, const std::string &newHash) const
 Updates an authentication token. More...
 
void setAuthenticated (bool success) const
 Logs the result of an authentication attempt. More...
 
int failedLoginAttempts () const
 Returns the number of consecutive unsuccessful login attempts. More...
 
WDateTime lastLoginAttempt () const
 Returns the last login attempt. More...
 

Detailed Description

A user.

This class represents a user. It is a value class that stores only the user id and a reference to an AbstractUserDatabase to access its properties.

An object can point to a valid user, or be invalid. Invalid users are typically used as return value for database queries which did not match with an existing user.

Not all methods are valid or applicable to your authentication system. See AbstractUserDatabase for a discussion.

See Also
AbstractUserDatabase

Member Enumeration Documentation

Enumeration for an email token stored for the user.

Enumerator
VerifyEmail 

Token is used to verify his email address.

LostPassword 

Token is used to allow the user to enter a new password.

Enumeration for a user's account status.

See Also
status()
Enumerator
Disabled 

Successfully identified but not allowed to log in.

Normal 

Normal status.

Constructor & Destructor Documentation

Wt::Auth::User::User ( )

Default constructor.

Creates an invalid user.

See Also
isValid()
Wt::Auth::User::User ( const std::string &  id,
const AbstractUserDatabase database 
)

Constructor.

Creates a user with id id, and whose information is stored in the database.

Member Function Documentation

void Wt::Auth::User::addAuthToken ( const Token token) const

Adds an authentication token.

See Also
AbstractUserDatabase::addAuthToken()
void Wt::Auth::User::addIdentity ( const std::string &  provider,
const WString identity 
)

Adds an identity.

Depending on whether the database supports multiple identities per provider, this may change (like setIdentity()), or add another identity to the user. For some identity providers (e.g. a 3rd party identity provider), it may be sensible to have more than one identity of the same provider for a single user (e.g. multiple email accounts managed by the same provider, that in fact identify the same user).

void Wt::Auth::User::clearEmailToken ( ) const

Clears the email token.

See Also
setEmailToken()
AbstractUserDatabase* Wt::Auth::User::database ( ) const

Returns the user database.

This returns the user database passed in the constructor, or 0 if the user is invalid, and was constructed using the default constructor.

std::string Wt::Auth::User::email ( ) const

Returns the email address.

See Also
AbstractUserDatabase::email()
Token Wt::Auth::User::emailToken ( ) const

Returns the email token.

See Also
AbstractUserDatabase::emailToken()
User::EmailTokenRole Wt::Auth::User::emailTokenRole ( ) const

Returns the email token role.

See Also
AbstractUserDatabase::emailTokenRole()
int Wt::Auth::User::failedLoginAttempts ( ) const

Returns the number of consecutive unsuccessful login attempts.

See Also
setAuthenticated()
const std::string& Wt::Auth::User::id ( ) const

Returns the user id.

This returns the id that uniquely identifies the user, and acts as a "primary key" to obtain other information for the user in the database.

See Also
AbstractUserDatabase
bool Wt::Auth::User::isValid ( ) const

Returns whether the user is valid.

A invalid user is a sentinel value returned by methods that query the database but could not identify a matching user.

WDateTime Wt::Auth::User::lastLoginAttempt ( ) const

Returns the last login attempt.

See Also
setAuthenticated()
bool Wt::Auth::User::operator!= ( const User other) const

Comparison operator.

See Also
operator==
bool Wt::Auth::User::operator== ( const User other) const

Comparison operator.

Two users are equal if they have the same identity and the same database.

PasswordHash Wt::Auth::User::password ( ) const

Returns the password.

See Also
AbstractUserDatabase::password()
void Wt::Auth::User::removeAuthToken ( const std::string &  hash) const

Removes an authentication token.

See Also
AbstractUserDatabase::removeAuthToken()
void Wt::Auth::User::removeIdentity ( const std::string &  provider)

Removes an identity.

See Also
addIdentity()
void Wt::Auth::User::setAuthenticated ( bool  success) const

Logs the result of an authentication attempt.

This changes the number of failed login attempts, and stores the current date as the last login attempt time.

See Also
failedLoginAttempts(), lastLoginAttempt()
void Wt::Auth::User::setEmail ( const std::string &  address) const

Sets the email address.

See Also
AbstractUserDatabase::setEmail()
void Wt::Auth::User::setEmailToken ( const Token token,
EmailTokenRole  role 
) const

Sets an email token.

See Also
AbstractUserDatabase::setEmailToken()
void Wt::Auth::User::setIdentity ( const std::string &  provider,
const WString identity 
)

Sets an identity.

Unlike addIdentity() this overrides any other identity of the given provider, in case the underlying database supports multiple identities per user.

void Wt::Auth::User::setPassword ( const PasswordHash password) const

Sets a password.

See Also
AbstractUserDatabase::setPassword()
void Wt::Auth::User::setUnverifiedEmail ( const std::string &  address) const

Sets the unverified email address.

See Also
AbstractUserDatabase::setUnverifiedEmail()
User::Status Wt::Auth::User::status ( ) const

Returns the account status.

See Also
AbstractUserDatabase::status()
std::string Wt::Auth::User::unverifiedEmail ( ) const

Returns the unverified email address.

See Also
AbstractUserDatabase::unverifiedEmail()
int Wt::Auth::User::updateAuthToken ( const std::string &  hash,
const std::string &  newHash 
) const

Updates an authentication token.

See Also
AbstractUserDatabase::updateAuthToken()

Generated on Wed Mar 12 2014 for the C++ Web Toolkit (Wt) by doxygen 1.8.4