The Battle for Wesnoth  1.15.2+dev
Classes | Public Types | Public 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  ban_info
 Ban status description. More...
 
struct  error
 

Public Types

enum  BAN_TYPE { BAN_NONE, BAN_USER, BAN_IP, BAN_EMAIL }
 Ban type values. More...
 

Public Member Functions

 user_handler ()
 
virtual ~user_handler ()
 
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 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...
 
virtual ban_info user_is_banned (const std::string &name, const std::string &addr="")=0
 Returns true if this user account or IP address is banned. More...
 
std::string create_unsecure_nonce (int length=8)
 Create a random string of digits for password encryption. More...
 
std::string create_secure_nonce ()
 
virtual std::string extract_salt (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...
 
virtual std::string get_uuid ()=0
 
virtual void db_insert_game_info (const std::string &uuid, int game_id, const std::string &version, const std::string &name)=0
 
virtual 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)=0
 
virtual void db_update_game_end (const std::string &uuid, int game_id, const std::string &replay_location)=0
 
virtual 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)=0
 
virtual void db_insert_modification_info (const std::string &uuid, int game_id, const std::string &modification_name)=0
 
virtual void db_set_oos_flag (const std::string &uuid, int game_id)=0
 

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 29 of file user_handler.hpp.

Member Enumeration Documentation

◆ BAN_TYPE

Ban type values.

Enumerator
BAN_NONE 

Not a ban.

BAN_USER 

User account/name ban.

BAN_IP 

IP address ban.

BAN_EMAIL 

Account email address ban.

Definition at line 79 of file user_handler.hpp.

Constructor & Destructor Documentation

◆ user_handler()

user_handler::user_handler ( )
inline

Definition at line 38 of file user_handler.hpp.

◆ ~user_handler()

virtual user_handler::~user_handler ( )
inlinevirtual

Member Function Documentation

◆ create_secure_nonce()

std::string user_handler::create_secure_nonce ( )

Definition at line 50 of file user_handler.cpp.

References base64::encode().

Referenced by user_handler::error::error().

◆ create_unsecure_nonce()

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

Create a random string of digits for password encryption.

Definition at line 30 of file user_handler.cpp.

References randomness::rng::default_instance(), randomness::rng::get_random_int(), and i.

Referenced by user_handler::error::error().

◆ db_insert_game_info()

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

Implemented in fuh.

Referenced by user_handler::error::error().

◆ db_insert_game_player_info()

virtual void user_handler::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 
)
pure virtual

Implemented in fuh.

Referenced by user_handler::error::error().

◆ db_insert_modification_info()

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

Implemented in fuh.

Referenced by user_handler::error::error().

◆ db_set_oos_flag()

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

Implemented in fuh.

Referenced by user_handler::error::error().

◆ db_update_game_end()

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

Implemented in fuh.

Referenced by user_handler::error::error().

◆ db_update_game_start()

virtual void user_handler::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 
)
pure virtual

Implemented in fuh.

Referenced by user_handler::error::error().

◆ extract_salt()

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

Referenced by user_handler::error::error().

◆ get_uuid()

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

Implemented in fuh.

Referenced by user_handler::error::error().

◆ login()

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.

Referenced by ~user_handler().

◆ set_is_moderator()

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.

Referenced by ~user_handler().

◆ use_phpbb_encryption()

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.

Referenced by user_handler::error::error().

◆ user_exists()

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.

Referenced by ~user_handler().

◆ user_info()

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.

Referenced by ~user_handler().

◆ user_is_active()

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.

Referenced by ~user_handler().

◆ user_is_banned()

virtual ban_info user_handler::user_is_banned ( const std::string &  name,
const std::string &  addr = "" 
)
pure 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.

Implemented in fuh.

Referenced by user_handler::ban_info::ban_info().

◆ user_is_moderator()

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.

Referenced by ~user_handler().

◆ user_logged_in()

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.

Referenced by ~user_handler().


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