Wt: Wt::Auth::Dbo::AuthInfo< UserType > Class Template Reference

Wt 4.10.4

Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
Wt::Auth::Dbo::AuthInfo< UserType > Class Template Reference

A default implementation for authentication data in Wt::Dbo. More...

`#include <Wt/Auth/Dbo/AuthInfo.h>`

Inheritance diagram for Wt::Auth::Dbo::AuthInfo< UserType >:
[legend]

## Public Types
typedef AuthToken< AuthInfo< UserType > > | AuthTokenType
| Type for an auth token.
typedef Wt::Dbo::collection< Wt::Dbo::ptr< AuthTokenType > > | AuthTokens
| Type for a collection of auth tokens.
typedef AuthIdentity< AuthInfo< UserType > > | AuthIdentityType
| Type for an identity.
typedef Wt::Dbo::collection< Wt::Dbo::ptr< AuthIdentityType > > | AuthIdentities
| Type for a collection of identites.

## Public Member Functions
| AuthInfo ()
| Constructor.
void | setUser (Wt::Dbo::ptr< UserType > user)
| Sets the user.
Wt::Dbo::ptr< UserType > | user () const
| Returns a reference to the user.
void | setPassword (const std::string &hash, const std::string &hashFunction, const std::string &hashSalt)
| Sets a password.
const std::string & | passwordHash () const
| Returns the password hash.
const std::string & | passwordMethod () const
| Returns the password method.
const std::string & | passwordSalt () const
| Returns the password salt.
void | setEmail (const std::string &email)
| Sets the email address.
const std::string & | email () const
| Returns the email address.
void | setUnverifiedEmail (const std::string &email)
| Sets the unverified email address.
const std::string & | unverifiedEmail () const
| Returns the unverified email address.
void | setEmailToken (const std::string &hash, const WDateTime &expires, EmailTokenRole role)
| Sets the email token.
const std::string & | emailToken () const
| Returns the email token.
const Wt::WDateTime & | emailTokenExpires () const
| Returns the email token expiration date.
EmailTokenRole | emailTokenRole () const
| Returns the email token role.
void | setStatus (AccountStatus status)
| Sets the status.
AccountStatus | status () const
| Returns the status.
void | setFailedLoginAttempts (int count)
| Sets the number of failed login attempts.
int | failedLoginAttempts () const
| Returns the number of failed login attempts.
void | setLastLoginAttempt (const Wt::WDateTime &dt)
| Sets the time of the last login attempt.
const Wt::WDateTime & | lastLoginAttempt () const
| Returns the time of the last login attempt.
const AuthTokens & | authTokens () const
| Returns the authentication tokens (read-only).
AuthTokens & | authTokens ()
| Returns the authentication tokens.
const AuthIdentities & | authIdentities () const
| Returns the authentication identities (read-only).
AuthIdentities & | authIdentities ()
| Returns the authentication identities.
WString | identity (const std::string &provider) const
| Finds an identity of a particular provider.
template<class Action >
void | persist (Action &a)
| Wt::Dbo persist implementation.
Public Member Functions inherited from Wt::Dbo::Dbo< AuthInfo< UserType > >
| Dbo ()
| Constructor.
| Dbo (const Dbo< AuthInfo< UserType > > &other)
| Copy constructor.
dbo_traits< AuthInfo< UserType > >::IdType | id () const
| Returns the database id.
Session * | session () const
| Returns the session.
void | setDirty ()
| Marks the object as modified.
bool | isDirty () const
| Returns whether this object is dirty.
ptr< AuthInfo< UserType > > | self () const
| Returns a dbo::ptr to this object.

## Detailed Description

template<class UserType>
class Wt::Auth::Dbo::AuthInfo< UserType >

A default implementation for authentication data in Wt::Dbo.

This class implements the requirements for use as a data type in Wt::Auth::Dbo::UserDatabase.

It is a template class, and needs as parameter the Dbo type which models a user (e.g. name, birth date, ...). Thus, this class only carries the authentication information for that user.

It contains collections to two other types:

- authTokens() references a collection of authentication tokens, see AuthService::setAuthTokensEnabled()
- authIdentities() references a collection of identities, which represent all the authentication identities this user has (e.g. a login name, but also an OAuth identity, etc...)

To use these classes, you need to map three classes to tables of your choice.

class User; // your user Dbo type
using AuthInfo = Wt::Auth::Dbo::AuthInfo<User>;
session->mapClass<User>("user");
session->mapClass<AuthInfo>("auth_info");
session->mapClass<AuthInfo::AuthIdentityType>("auth_identity");
session->mapClass<AuthInfo::AuthTokenType>("auth_token");
Wt::Auth::Dbo::AuthIdentity
A default implementation for a authentication identity in Wt::Dbo.
Definition AuthInfo.h:354
Wt::Auth::Dbo::AuthInfo
A default implementation for authentication data in Wt::Dbo.
Definition WGlobal.h:237
Wt::Auth::Dbo::AuthToken
A default implementation for an authentication token in Wt::Dbo.
Definition AuthInfo.h:300
Wt::Auth::User
A user.
Definition User.h:55
Wt::Dbo::Dbo< AuthInfo< UserType > >::session
Session * session() const
Definition ptr_impl.h:679
Wt::Dbo::Session::mapClass
void mapClass(const char *tableName)
Maps a class to a database table.
Definition Session_impl.h:40

See also
  UserDatabase

## Member Function Documentation

## ◆ email()

template<class UserType >

const std::string & Wt::Auth::Dbo::AuthInfo< UserType >::email | ( |  | ) | const

Returns the email address.

See also
  setEmail()

## ◆ emailToken()

template<class UserType >

const std::string & Wt::Auth::Dbo::AuthInfo< UserType >::emailToken | ( |  | ) | const

Returns the email token.

See also
  setEmailToken()

## ◆ emailTokenExpires()

template<class UserType >

const Wt::WDateTime & Wt::Auth::Dbo::AuthInfo< UserType >::emailTokenExpires | ( |  | ) | const

Returns the email token expiration date.

See also
  setEmailToken()

## ◆ emailTokenRole()

template<class UserType >

EmailTokenRole Wt::Auth::Dbo::AuthInfo< UserType >::emailTokenRole | ( |  | ) | const

Returns the email token role.

See also
  setEmailToken()

## ◆ failedLoginAttempts()

template<class UserType >

int Wt::Auth::Dbo::AuthInfo< UserType >::failedLoginAttempts | ( |  | ) | const

Returns the number of failed login attempts.

See also
  failedLoginAttempts()

## ◆ identity()

template<class UserType >

WString Wt::Auth::Dbo::AuthInfo< UserType >::identity | ( | const std::string & | provider | ) | const

Finds an identity of a particular provider.

Note, a user could in theory have multiple identities from a single provider. If there are multiple, only one of them is returned.

## ◆ lastLoginAttempt()

template<class UserType >

const Wt::WDateTime & Wt::Auth::Dbo::AuthInfo< UserType >::lastLoginAttempt | ( |  | ) | const

Returns the time of the last login attempt.

See also
  setLastLoginAttempt()

## ◆ passwordHash()

template<class UserType >

const std::string & Wt::Auth::Dbo::AuthInfo< UserType >::passwordHash | ( |  | ) | const

Returns the password hash.

See also
  setPassword()

## ◆ passwordMethod()

template<class UserType >

const std::string & Wt::Auth::Dbo::AuthInfo< UserType >::passwordMethod | ( |  | ) | const

Returns the password method.

See also
  setPassword()

## ◆ passwordSalt()

template<class UserType >

const std::string & Wt::Auth::Dbo::AuthInfo< UserType >::passwordSalt | ( |  | ) | const

Returns the password salt.

See also
  setPassword()

## ◆ setUser()

template<class UserType >

void Wt::Auth::Dbo::AuthInfo< UserType >::setUser | ( | Wt::Dbo::ptr< UserType > | user | ) |

Sets the user.

This sets the user that owns this authentication information.

## ◆ status()

template<class UserType >

AccountStatus Wt::Auth::Dbo::AuthInfo< UserType >::status | ( |  | ) | const

Returns the status.

See also
  setStatus()

## ◆ unverifiedEmail()

template<class UserType >

const std::string & Wt::Auth::Dbo::AuthInfo< UserType >::unverifiedEmail | ( |  | ) | const

Returns the unverified email address.

See also
  setUnverifiedEmail()

## ◆ user()

template<class UserType >

Wt::Dbo::ptr< UserType > Wt::Auth::Dbo::AuthInfo< UserType >::user | ( |  | ) | const

Returns a reference to the user.

See also
  setUser()