The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
fuh Class Reference

A user_handler implementation to link the server with a phpbb3 forum. More...

#include <forum_user_handler.hpp>

Inheritance diagram for fuh:
Inheritance graph

Public Member Functions

 fuh (const config &c)
 
 ~fuh ()
 
void add_user (const std::string &name, const std::string &mail, const std::string &password)
 Adds a user. More...
 
void remove_user (const std::string &name)
 Removes a user. More...
 
void clean_up ()
 Called by the server once a day. More...
 
bool login (const std::string &name, const std::string &password, const std::string &seed)
 Return true if the given password matches the password for the given user. More...
 
std::string create_pepper (const std::string &name)
 Needed because the hashing algorithm used by phpbb requires some info from the original hash to recreate the same hash. More...
 
void user_logged_in (const std::string &name)
 Executed when the user with the given name logged in. More...
 
bool user_exists (const std::string &name)
 Returns true if a user with the given name exists. More...
 
bool user_is_active (const std::string &name)
 Returns true if the specified user account is usable for logins. More...
 
bool user_is_moderator (const std::string &name)
 Returns true if this user is a moderator on this server. More...
 
void set_is_moderator (const std::string &name, const bool &is_moderator)
 Mark this user as a moderator. More...
 
void password_reminder (const std::string &name)
 Send a password reminder email to the given user. More...
 
std::string user_info (const std::string &name)
 Returns a string containing info like the last login of this user. More...
 
void set_user_detail (const std::string &user, const std::string &detail, const std::string &value)
 Set data for a given user name. More...
 
std::string get_valid_details ()
 List of details that can be set for this user_handler. More...
 
bool use_phpbb_encryption () const
 Does this user_handler want passwords passed encrypted using phpbb's algorithm? More...
 
- Public Member Functions inherited from user_handler
 user_handler ()
 
virtual ~user_handler ()
 
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...
 

Private Types

typedef std::unique_ptr
< MYSQL_RES, decltype(&mysql_free_result)> 
mysql_result
 

Private Member Functions

std::string get_hash (const std::string &user)
 
std::string get_mail (const std::string &user)
 Used in send_mail(). More...
 
time_t get_lastlogin (const std::string &user)
 
time_t get_registrationdate (const std::string &user)
 
bool is_inactive (const std::string &user)
 
void set_lastlogin (const std::string &user, const time_t &lastlogin)
 
mysql_result db_query (const std::string &query)
 
std::string db_query_to_string (const std::string &query)
 
std::string get_detail_for_user (const std::string &name, const std::string &detail)
 
std::string get_writable_detail_for_user (const std::string &name, const std::string &detail)
 
void write_detail (const std::string &name, const std::string &detail, const std::string &value)
 
bool extra_row_exists (const std::string &name)
 

Private Attributes

std::string db_name_
 
std::string db_host_
 
std::string db_user_
 
std::string db_password_
 
std::string db_users_table_
 
std::string db_extra_table_
 
MYSQL * conn
 

Additional Inherited Members

- Protected Member Functions inherited from user_handler
bool send_mail (const std::string &to_user, const std::string &subject, const std::string &message)
 Sends an email to the specified address. More...
 

Detailed Description

A user_handler implementation to link the server with a phpbb3 forum.

Definition at line 40 of file forum_user_handler.hpp.

Member Typedef Documentation

typedef std::unique_ptr<MYSQL_RES, decltype(&mysql_free_result)> fuh::mysql_result
private

Definition at line 97 of file forum_user_handler.hpp.

Constructor & Destructor Documentation

fuh::fuh ( const config c)
fuh::~fuh ( )

Member Function Documentation

void fuh::add_user ( const std::string name,
const std::string mail,
const std::string password 
)
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).

Implements user_handler.

void fuh::clean_up ( )
inlinevirtual

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.

Implements user_handler.

Definition at line 51 of file forum_user_handler.hpp.

std::string fuh::create_pepper ( const std::string name)
virtual

Needed because the hashing algorithm used by phpbb requires some info from the original hash to recreate the same hash.

Return an empty string if an error occurs

Implements user_handler.

mysql_result fuh::db_query ( const std::string query)
private
std::string fuh::db_query_to_string ( const std::string query)
private
bool fuh::extra_row_exists ( const std::string name)
private
std::string fuh::get_detail_for_user ( const std::string name,
const std::string detail 
)
private
std::string fuh::get_hash ( const std::string user)
private
time_t fuh::get_lastlogin ( const std::string user)
private
std::string fuh::get_mail ( const std::string user)
privatevirtual

Used in send_mail().

Should return an empty string when not used.

Implements user_handler.

time_t fuh::get_registrationdate ( const std::string user)
private
std::string fuh::get_valid_details ( )
virtual

List of details that can be set for this user_handler.

Implements user_handler.

std::string fuh::get_writable_detail_for_user ( const std::string name,
const std::string detail 
)
private
bool fuh::is_inactive ( const std::string user)
private
bool fuh::login ( const std::string name,
const std::string password,
const std::string seed 
)
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

Implements user_handler.

void fuh::password_reminder ( const std::string name)
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).

Implements user_handler.

void fuh::remove_user ( const std::string name)
virtual

Removes a user.

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

Implements user_handler.

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

Mark this user as a moderator.

Implements user_handler.

void fuh::set_lastlogin ( const std::string user,
const time_t &  lastlogin 
)
private
void fuh::set_user_detail ( const std::string user,
const std::string detail,
const std::string value 
)
virtual

Set data for a given user name.

Should throw an error on invalid data.

Implements user_handler.

bool fuh::use_phpbb_encryption ( ) const
inlinevirtual

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.

Implements user_handler.

Definition at line 82 of file forum_user_handler.hpp.

bool fuh::user_exists ( const std::string name)
virtual

Returns true if a user with the given name exists.

Implements user_handler.

std::string fuh::user_info ( const std::string name)
virtual

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

Formatted for user readable output.

Implements user_handler.

bool fuh::user_is_active ( const std::string name)
virtual

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

Implements user_handler.

bool fuh::user_is_moderator ( const std::string name)
virtual

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

Implements user_handler.

void fuh::user_logged_in ( const std::string name)
virtual

Executed when the user with the given name logged in.

Implements user_handler.

void fuh::write_detail ( const std::string name,
const std::string detail,
const std::string value 
)
private

Member Data Documentation

MYSQL* fuh::conn
private

Definition at line 104 of file forum_user_handler.hpp.

std::string fuh::db_extra_table_
private

Definition at line 95 of file forum_user_handler.hpp.

std::string fuh::db_host_
private

Definition at line 95 of file forum_user_handler.hpp.

std::string fuh::db_name_
private

Definition at line 95 of file forum_user_handler.hpp.

std::string fuh::db_password_
private

Definition at line 95 of file forum_user_handler.hpp.

std::string fuh::db_user_
private

Definition at line 95 of file forum_user_handler.hpp.

std::string fuh::db_users_table_
private

Definition at line 95 of file forum_user_handler.hpp.


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