The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Classes | Public Member Functions | Protected Member Functions | List of all members
user_handler Class Referenceabstract

An interface class to handle nick registration To activate it put a [user_handler] section into the server configuration file. More...

#include <user_handler.hpp>

Inheritance diagram for user_handler:
Inheritance graph

Classes

struct  error
 

Public Member Functions

 user_handler ()
 
virtual ~user_handler ()
 
virtual void add_user (const std::string &name, const std::string &mail, const std::string &password)=0
 Adds a user. More...
 
virtual void remove_user (const std::string &name)=0
 Removes a user. More...
 
virtual void clean_up ()=0
 Called by the server once a day. More...
 
virtual void password_reminder (const std::string &name)=0
 Send a password reminder email to the given user. More...
 
virtual bool login (const std::string &name, const std::string &password, const std::string &seed)=0
 Return true if the given password matches the password for the given user. More...
 
virtual void user_logged_in (const std::string &name)=0
 Executed when the user with the given name logged in. More...
 
virtual std::string user_info (const std::string &name)=0
 Returns a string containing info like the last login of this user. More...
 
virtual void set_user_detail (const std::string &user, const std::string &detail, const std::string &value)=0
 Set data for a given user name. More...
 
virtual std::string get_valid_details ()=0
 List of details that can be set for this user_handler. More...
 
virtual bool user_exists (const std::string &name)=0
 Returns true if a user with the given name exists. More...
 
virtual bool user_is_active (const std::string &name)=0
 Returns true if the specified user account is usable for logins. More...
 
virtual bool user_is_moderator (const std::string &name)=0
 Returns true if this user is a moderator on this server. More...
 
virtual void set_is_moderator (const std::string &name, const bool &is_moderator)=0
 Mark this user as a moderator. More...
 
void init_mailer (const config &c)
 Initiate the mailer object. More...
 
std::string create_salt (int length=8)
 Create a random string of digits for password encryption. More...
 
virtual std::string create_pepper (const std::string &username)=0
 Create custom salt. More...
 
virtual bool use_phpbb_encryption () const =0
 Does this user_handler want passwords passed encrypted using phpbb's algorithm? More...
 

Protected Member Functions

bool send_mail (const std::string &to_user, const std::string &subject, const std::string &message)
 Sends an email to the specified address. More...
 
virtual std::string get_mail (const std::string &user)=0
 Used in send_mail(). More...
 

Detailed Description

An interface class to handle nick registration To activate it put a [user_handler] section into the server configuration file.

Definition at line 30 of file user_handler.hpp.

Constructor & Destructor Documentation

user_handler::user_handler ( )
inline

Definition at line 39 of file user_handler.hpp.

virtual user_handler::~user_handler ( )
inlinevirtual

Definition at line 43 of file user_handler.hpp.

Member Function Documentation

virtual void user_handler::add_user ( const std::string name,
const std::string mail,
const std::string password 
)
pure virtual

Adds a user.

Throws an error containing the error message if adding fails (e.g. because a user with the same name already exists).

Implemented in fuh, and suh.

virtual void user_handler::clean_up ( )
pure virtual

Called by the server once a day.

Could for example be used for removing users that have not logged in for a certain amount of time.

Implemented in fuh, and suh.

virtual std::string user_handler::create_pepper ( const std::string username)
pure virtual

Create custom salt.

If not needed let it return and empty string or whatever you feel like.

Implemented in suh, and fuh.

std::string user_handler::create_salt ( int  length = 8)

Create a random string of digits for password encryption.

Definition at line 40 of file user_handler.cpp.

References i.

virtual std::string user_handler::get_mail ( const std::string user)
protectedpure virtual

Used in send_mail().

Should return an empty string when not used.

Implemented in fuh, and suh.

Referenced by send_mail().

virtual std::string user_handler::get_valid_details ( )
pure virtual

List of details that can be set for this user_handler.

Implemented in fuh, and suh.

void user_handler::init_mailer ( const config c)

Initiate the mailer object.

Definition at line 37 of file user_handler.cpp.

virtual bool user_handler::login ( const std::string name,
const std::string password,
const std::string seed 
)
pure virtual

Return true if the given password matches the password for the given user.

Password could also be a hash Seed is not needed for clear text log ins Currently the login procedure in the server and client code is hardcoded for the forum_user_handler implementation

Implemented in fuh, and suh.

virtual void user_handler::password_reminder ( const std::string name)
pure virtual

Send a password reminder email to the given user.

Should throw user_handler::error if sending fails (e.g. because we cannot send email).

Implemented in fuh, and suh.

virtual void user_handler::remove_user ( const std::string name)
pure virtual

Removes a user.

Throws an error containing the error message if removing fails (e.g. no user with the given name exists).

Implemented in fuh, and suh.

bool user_handler::send_mail ( const std::string to_user,
const std::string subject,
const std::string message 
)
protected

Sends an email to the specified address.

Requires access to an SMTP server.

Throws an error if the mail could not be sent.

Definition at line 21 of file user_handler.cpp.

References error(), get_mail(), and user_exists().

Referenced by suh::password_reminder().

virtual void user_handler::set_is_moderator ( const std::string name,
const bool &  is_moderator 
)
pure virtual

Mark this user as a moderator.

Implemented in fuh, and suh.

virtual void user_handler::set_user_detail ( const std::string user,
const std::string detail,
const std::string value 
)
pure virtual

Set data for a given user name.

Should throw an error on invalid data.

Implemented in fuh, and suh.

virtual bool user_handler::use_phpbb_encryption ( ) const
pure virtual

Does this user_handler want passwords passed encrypted using phpbb's algorithm?

Let it return true if it does and false if it does not.

Implemented in fuh, and suh.

virtual bool user_handler::user_exists ( const std::string name)
pure virtual

Returns true if a user with the given name exists.

Implemented in fuh, and suh.

Referenced by send_mail().

virtual std::string user_handler::user_info ( const std::string name)
pure virtual

Returns a string containing info like the last login of this user.

Formatted for user readable output.

Implemented in fuh, and suh.

virtual bool user_handler::user_is_active ( const std::string name)
pure virtual

Returns true if the specified user account is usable for logins.

Implemented in fuh, and suh.

virtual bool user_handler::user_is_moderator ( const std::string name)
pure virtual

Returns true if this user is a moderator on this server.

Implemented in fuh, and suh.

virtual void user_handler::user_logged_in ( const std::string name)
pure virtual

Executed when the user with the given name logged in.

Implemented in fuh, and suh.


The documentation for this class was generated from the following files: