The Battle for Wesnoth  1.15.2+dev
Public Member Functions | 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 ()
 
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 extract_salt (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...
 
ban_info user_is_banned (const std::string &name, const std::string &addr)
 Returns true if this user account or IP address is banned. More...
 
std::string user_info (const std::string &name)
 Returns a string containing info like the last login of this user. More...
 
bool use_phpbb_encryption () const
 Does this user_handler want passwords passed encrypted using phpbb's algorithm? More...
 
std::string get_uuid ()
 
void db_insert_game_info (const std::string &uuid, int game_id, const std::string &version, const std::string &name)
 
void db_update_game_start (const std::string &uuid, int game_id, const std::string &map_name, const std::string &era_name, int reload, int observers, int is_public, int has_password)
 
void db_update_game_end (const std::string &uuid, int game_id, const std::string &replay_location)
 
void db_insert_game_player_info (const std::string &uuid, int game_id, const std::string &username, int side_number, int is_host, const std::string &faction, const std::string &version, const std::string &source, const std::string &current_user)
 
void db_insert_modification_info (const std::string &uuid, int game_id, const std::string &modification_name)
 
void db_set_oos_flag (const std::string &uuid, int game_id)
 
- Public Member Functions inherited from user_handler
 user_handler ()
 
virtual ~user_handler ()
 
std::string create_unsecure_nonce (int length=8)
 Create a random string of digits for password encryption. More...
 
std::string create_secure_nonce ()
 

Private Member Functions

std::string get_hash (const std::string &user)
 
std::time_t get_lastlogin (const std::string &user)
 
std::time_t get_registrationdate (const std::string &user)
 
bool is_inactive (const std::string &user)
 
void set_lastlogin (const std::string &user, const std::time_t &lastlogin)
 
template<typename T >
ban_info retrieve_ban_info (BAN_TYPE, T detail)
 
std::time_t retrieve_ban_duration_internal (const std::string &col, const std::string &detail)
 
std::time_t retrieve_ban_duration_internal (const std::string &col, unsigned int detail)
 
template<typename T , typename... Args>
prepared_statement (const std::string &sql, Args &&...)
 
template<typename T >
get_detail_for_user (const std::string &name, const std::string &detail)
 
template<typename T >
get_writable_detail_for_user (const std::string &name, const std::string &detail)
 
template<typename T >
void write_detail (const std::string &name, const std::string &detail, T &&value)
 
bool extra_row_exists (const std::string &name)
 
bool is_user_in_group (const std::string &name, unsigned int group_id)
 

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_banlist_table_
 
std::string db_extra_table_
 
std::string db_game_info_table_
 
std::string db_game_player_info_table_
 
std::string db_game_modification_info_table_
 
std::string db_user_group_table_
 
unsigned int mp_mod_group_
 
MYSQL * conn
 

Additional Inherited Members

- Public Types inherited from user_handler
enum  BAN_TYPE { BAN_NONE, BAN_USER, BAN_IP, BAN_EMAIL }
 Ban type values. More...
 

Detailed Description

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

Definition at line 41 of file forum_user_handler.hpp.

Constructor & Destructor Documentation

◆ fuh()

fuh::fuh ( const config c)

◆ ~fuh()

fuh::~fuh ( )

Member Function Documentation

◆ db_insert_game_info()

void fuh::db_insert_game_info ( const std::string &  uuid,
int  game_id,
const std::string &  version,
const std::string &  name 
)
virtual

Implements user_handler.

Referenced by use_phpbb_encryption().

◆ db_insert_game_player_info()

void fuh::db_insert_game_player_info ( const std::string &  uuid,
int  game_id,
const std::string &  username,
int  side_number,
int  is_host,
const std::string &  faction,
const std::string &  version,
const std::string &  source,
const std::string &  current_user 
)
virtual

Implements user_handler.

Referenced by use_phpbb_encryption().

◆ db_insert_modification_info()

void fuh::db_insert_modification_info ( const std::string &  uuid,
int  game_id,
const std::string &  modification_name 
)
virtual

Implements user_handler.

Referenced by use_phpbb_encryption().

◆ db_set_oos_flag()

void fuh::db_set_oos_flag ( const std::string &  uuid,
int  game_id 
)
virtual

Implements user_handler.

Referenced by use_phpbb_encryption().

◆ db_update_game_end()

void fuh::db_update_game_end ( const std::string &  uuid,
int  game_id,
const std::string &  replay_location 
)
virtual

Implements user_handler.

Referenced by use_phpbb_encryption().

◆ db_update_game_start()

void fuh::db_update_game_start ( const std::string &  uuid,
int  game_id,
const std::string &  map_name,
const std::string &  era_name,
int  reload,
int  observers,
int  is_public,
int  has_password 
)
virtual

Implements user_handler.

Referenced by use_phpbb_encryption().

◆ extra_row_exists()

bool fuh::extra_row_exists ( const std::string &  name)
private

◆ extract_salt()

std::string fuh::extract_salt ( 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.

◆ get_detail_for_user()

template<typename T >
T fuh::get_detail_for_user ( const std::string &  name,
const std::string &  detail 
)
private

◆ get_hash()

std::string fuh::get_hash ( const std::string &  user)
private

Referenced by use_phpbb_encryption().

◆ get_lastlogin()

std::time_t fuh::get_lastlogin ( const std::string &  user)
private

Referenced by use_phpbb_encryption().

◆ get_registrationdate()

std::time_t fuh::get_registrationdate ( const std::string &  user)
private

Referenced by use_phpbb_encryption().

◆ get_uuid()

std::string fuh::get_uuid ( )
virtual

Implements user_handler.

Referenced by use_phpbb_encryption().

◆ get_writable_detail_for_user()

template<typename T >
T fuh::get_writable_detail_for_user ( const std::string &  name,
const std::string &  detail 
)
private

◆ is_inactive()

bool fuh::is_inactive ( const std::string &  user)
private

Referenced by use_phpbb_encryption().

◆ is_user_in_group()

bool fuh::is_user_in_group ( const std::string &  name,
unsigned int  group_id 
)
private

◆ login()

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.

◆ prepared_statement()

template<typename T , typename... Args>
T fuh::prepared_statement ( const std::string &  sql,
Args &&  ... 
)
inlineprivate

◆ retrieve_ban_duration_internal() [1/2]

std::time_t fuh::retrieve_ban_duration_internal ( const std::string &  col,
const std::string &  detail 
)
private

Referenced by use_phpbb_encryption().

◆ retrieve_ban_duration_internal() [2/2]

std::time_t fuh::retrieve_ban_duration_internal ( const std::string &  col,
unsigned int  detail 
)
private

◆ retrieve_ban_info()

template<typename T >
ban_info fuh::retrieve_ban_info ( BAN_TYPE  ,
detail 
)
private

Referenced by use_phpbb_encryption().

◆ set_is_moderator()

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

Mark this user as a moderator.

Implements user_handler.

◆ set_lastlogin()

void fuh::set_lastlogin ( const std::string &  user,
const std::time_t &  lastlogin 
)
private

Referenced by use_phpbb_encryption().

◆ use_phpbb_encryption()

bool fuh::use_phpbb_encryption ( ) const
inlinevirtual

◆ user_exists()

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

Returns true if a user with the given name exists.

Implements user_handler.

◆ user_info()

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.

◆ user_is_active()

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

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

Implements user_handler.

◆ user_is_banned()

ban_info fuh::user_is_banned ( const std::string &  name,
const std::string &  addr 
)
virtual

Returns true if this user account or IP address is banned.

Note
The IP address is only used by the forum_user_handler subclass. Regular IP ban checks are done by server_base instead.

Implements user_handler.

◆ user_is_moderator()

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

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

Implements user_handler.

◆ user_logged_in()

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

Executed when the user with the given name logged in.

Implements user_handler.

◆ write_detail()

template<typename T >
void fuh::write_detail ( const std::string &  name,
const std::string &  detail,
T &&  value 
)
private

Member Data Documentation

◆ conn

MYSQL* fuh::conn
private

Definition at line 97 of file forum_user_handler.hpp.

◆ db_banlist_table_

std::string fuh::db_banlist_table_
private

Definition at line 94 of file forum_user_handler.hpp.

◆ db_extra_table_

std::string fuh::db_extra_table_
private

Definition at line 94 of file forum_user_handler.hpp.

◆ db_game_info_table_

std::string fuh::db_game_info_table_
private

Definition at line 94 of file forum_user_handler.hpp.

◆ db_game_modification_info_table_

std::string fuh::db_game_modification_info_table_
private

Definition at line 94 of file forum_user_handler.hpp.

◆ db_game_player_info_table_

std::string fuh::db_game_player_info_table_
private

Definition at line 94 of file forum_user_handler.hpp.

◆ db_host_

std::string fuh::db_host_
private

Definition at line 94 of file forum_user_handler.hpp.

◆ db_name_

std::string fuh::db_name_
private

Definition at line 94 of file forum_user_handler.hpp.

◆ db_password_

std::string fuh::db_password_
private

Definition at line 94 of file forum_user_handler.hpp.

◆ db_user_

std::string fuh::db_user_
private

Definition at line 94 of file forum_user_handler.hpp.

◆ db_user_group_table_

std::string fuh::db_user_group_table_
private

Definition at line 94 of file forum_user_handler.hpp.

◆ db_users_table_

std::string fuh::db_users_table_
private

Definition at line 94 of file forum_user_handler.hpp.

◆ mp_mod_group_

unsigned int fuh::mp_mod_group_
private

Definition at line 95 of file forum_user_handler.hpp.


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