Wt
3.2.0
|
Model for implementing a registration view. More...
#include <Wt/Auth/RegistrationModel>
Public Types | |
enum | Field { LoginName, Password, Password2, Email } |
Enumeration for a field. More... | |
enum | EmailPolicy { EmailDisabled, EmailOptional, EmailMandatory } |
Enumeration for an email policy. More... | |
enum | IdentityConfirmationMethod { ConfirmWithPassword, ConfirmWithEmail, ConfirmationNotPossible } |
Method for confirming to be an existing user. More... | |
Public Member Functions | |
RegistrationModel (const AuthService &baseAuth, AbstractUserDatabase &users, Login &login, WObject *parent=0) | |
Constructor. | |
const AuthService * | baseAuth () const |
Returns the authentication base service. | |
Login & | login () |
Returns the login object. | |
AbstractUserDatabase & | users () |
Returns the user database. | |
void | addPasswordAuth (const AbstractPasswordService *auth) |
Adds a password authentication service. | |
const AbstractPasswordService * | passwordAuth () const |
Returns the password authentication service. | |
void | addOAuth (const OAuthService *auth) |
Adds an OAuth authentication service provider. | |
void | addOAuth (const std::vector< const OAuthService * > &auth) |
Adds a list of OAuth authentication service providers. | |
std::vector< const OAuthService * > | oAuth () const |
Returns the list of OAuth authentication service providers. | |
void | setMinLoginNameLength (int chars) |
Configures a minimum length for a login name. | |
int | minLoginNameLength () const |
Returns the minimum length for a login name. | |
void | setEmailPolicy (EmailPolicy policy) |
Configures whether an email address needs to be entered. | |
EmailPolicy | emailPolicy () const |
Returns the email policy. | |
virtual bool | registerIdentified (const Identity &identity) |
Register a user authenticated by an identity provider. | |
User | existingUser () const |
Returns the existing user that needs to be confirmed. | |
virtual IdentityConfirmationMethod | confirmIsExistingUser () const |
Returns the method to be used to confirm to be an existing user. | |
virtual void | existingUserConfirmed () |
Confirms that the user is indeed an existing user. | |
virtual WString | validateLoginName (const WString &userName) const |
Validates the login name. | |
virtual void | checkUserExists (const WString &userName) |
Verifies that a user with that name does not yet exist. | |
virtual bool | validate () |
Validates the current input. | |
bool | valid () const |
Returns the result of the last validation. | |
virtual User | doRegister () |
Performs the registration process. | |
virtual bool | isVisible (Field field) const |
Returns whether a field should be shown. | |
virtual bool | isReadOnly (Field field) const |
Returns whether a field is read only. | |
virtual WString | label (Field field) const |
Returns a field label. | |
virtual void | setValue (Field field, const WString &value) |
Sets the field value. | |
virtual const WString & | value (Field field) const |
Returns the field value. | |
virtual bool | validate (Field field) |
Validates a field. | |
const WValidator::Result & | validationResult (Field field) const |
Returns the result of a validation. | |
virtual bool | isConfirmUserButtonVisible () const |
Returns whether an existing user may be confirmed. | |
virtual bool | isFederatedLoginVisible () const |
Returns whether federated login options can be shown. |
Model for implementing a registration view.
This model implements the logic for the registration of a new user. It can deal with traditional username/password registration, or registration of pre-identified users using federated login.
Enumeration for a field.
LoginName |
Login name field. |
Password |
Password field. |
Password2 |
Repeat password field. |
Email field (if login name is not email) |
Wt::Auth::RegistrationModel::RegistrationModel | ( | const AuthService & | baseAuth, |
AbstractUserDatabase & | users, | ||
Login & | login, | ||
WObject * | parent = 0 |
||
) |
Constructor.
Creates a new registration model, using a basic authentication service and user database.
The login
object is used to indicate that an existing user was re-identified, and thus the registration process may be aborted.
void Wt::Auth::RegistrationModel::addOAuth | ( | const OAuthService * | auth | ) |
Adds an OAuth authentication service provider.
This enables OAuth-based registration. More than one OAuth authentication service can be configured: one for each supported third-party OAuth identity provider.
void Wt::Auth::RegistrationModel::addOAuth | ( | const std::vector< const OAuthService * > & | auth | ) |
Adds a list of OAuth authentication service providers.
void Wt::Auth::RegistrationModel::addPasswordAuth | ( | const AbstractPasswordService * | auth | ) |
Adds a password authentication service.
This enables password-based registration, including choosing a proper password.
Only one password authentication service can be configured.
const AuthService* Wt::Auth::RegistrationModel::baseAuth | ( | ) | const |
Returns the authentication base service.
This returns the service passed through the constructor.
void Wt::Auth::RegistrationModel::checkUserExists | ( | const WString & | userName | ) | [virtual] |
Verifies that a user with that name does not yet exist.
If a user with that name already exists, it may in fact be the same user that is trying to register again (perhaps using a different identification method). If possible, we allow the user to confirm his identity.
RegistrationModel::IdentityConfirmationMethod Wt::Auth::RegistrationModel::confirmIsExistingUser | ( | ) | const [virtual] |
Returns the method to be used to confirm to be an existing user.
When the ConfirmExisting field is visible, this returns an appropriate method to use to let the user confirm that he is indeed the identified existing user.
The outcome of this method (if it is an online method, like a password prompt), if successful should be indicated using existingUserConfirmed().
EmailPolicy Wt::Auth::RegistrationModel::emailPolicy | ( | ) | const |
Returns the email policy.
User Wt::Auth::RegistrationModel::existingUser | ( | ) | const |
Returns the existing user that needs to be confirmed.
When a user wishes to register with an identity that corresponds to an existing user, he ma be allowd to confirm that he is in fact this existing user.
void Wt::Auth::RegistrationModel::existingUserConfirmed | ( | ) | [virtual] |
Confirms that the user is indeed an existing user.
The new identity is added to this existing user (if applicable), and the user is logged in.
bool Wt::Auth::RegistrationModel::isConfirmUserButtonVisible | ( | ) | const [virtual] |
Returns whether an existing user may be confirmed.
This returns whether the user is being identified as an existing user and he can confirm that he is in fact the same user.
bool Wt::Auth::RegistrationModel::isFederatedLoginVisible | ( | ) | const [virtual] |
Returns whether federated login options can be shown.
This returns whether fields for federated login (such as OAuth) should be shown. These are typically buttons corresponding to identity providers.
The result of a federated authentication procedure should be indicated to registerIdentified().
int Wt::Auth::RegistrationModel::minLoginNameLength | ( | ) | const |
Returns the minimum length for a login name.
std::vector<const OAuthService *> Wt::Auth::RegistrationModel::oAuth | ( | ) | const |
Returns the list of OAuth authentication service providers.
const AbstractPasswordService* Wt::Auth::RegistrationModel::passwordAuth | ( | ) | const |
Returns the password authentication service.
bool Wt::Auth::RegistrationModel::registerIdentified | ( | const Identity & | identity | ) | [virtual] |
Register a user authenticated by an identity provider.
Using a 3rd party authentication service such as OAuth, a user may be identified which is not yet registered with the web application.
Then, you may still need to allow the user to complete registration, but because the user already is identified and authenticated, this simplifies the registration form, since fields related to authentication can be dropped.
Returns true
if the given identity was already registered, and has been logged in.
void Wt::Auth::RegistrationModel::setEmailPolicy | ( | EmailPolicy | policy | ) |
Configures whether an email address needs to be entered.
You may specify whether you want the user to enter an email address.
This has no effect when the IdentityPolicy is EmailAddressIdentity.
The default policy is:
void Wt::Auth::RegistrationModel::setMinLoginNameLength | ( | int | chars | ) |
Configures a minimum length for a login name.
The default value is 4.
bool Wt::Auth::RegistrationModel::valid | ( | ) | const |
Returns the result of the last validation.
bool Wt::Auth::RegistrationModel::validate | ( | ) | [virtual] |
Validates the current input.
If validation is successful, then a new user can be registered using doRegister()
bool Wt::Auth::RegistrationModel::validate | ( | Field | field | ) | [virtual] |
Validates a field.
Validates the login name.
This verifies that the login name is adequate (see also setMinLoginNameLength()).
const WValidator::Result & Wt::Auth::RegistrationModel::validationResult | ( | Field | field | ) | const |
Returns the result of a validation.