server/sample_user_handler.hpp

Go to the documentation of this file.
00001 /* $Id: sample_user_handler.hpp 52533 2012-01-07 02:35:17Z shadowmaster $ */
00002 /*
00003    Copyright (C) 2008 - 2012 by Thomas Baumhauer <thomas.baumhauer@NOSPAMgmail.com>
00004    Part of the Battle for Wesnoth Project http://www.wesnoth.org/
00005 
00006    This program is free software; you can redistribute it and/or modify
00007    it under the terms of the GNU General Public License as published by
00008    the Free Software Foundation; either version 2 of the License, or
00009    (at your option) any later version.
00010    This program is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY.
00012 
00013    See the COPYING file for more details.
00014 */
00015 
00016 #ifndef SAMPLE_USER_HANDLER_HPP_INCLUDED
00017 #define SAMPLE_USER_HANDLER_HPP_INCLUDED
00018 
00019 #include "user_handler.hpp"
00020 
00021 #include <map>
00022 #include <vector>
00023 
00024 #include <ctime>
00025 
00026 /**
00027  * An example of how to implement user_handler.
00028  * If you use this on anything real, you are insane.
00029  */
00030 class suh : public user_handler {
00031     public:
00032         suh(config c);
00033 
00034         void add_user(const std::string& name, const std::string& mail, const std::string& password);
00035         void remove_user(const std::string& name);
00036 
00037         void clean_up();
00038 
00039         bool login(const std::string& name, const std::string& password, const std::string&);
00040         void user_logged_in(const std::string& name);
00041 
00042         void password_reminder(const std::string& name);
00043 
00044         bool user_exists(const std::string& name);
00045         bool user_is_active(const std::string& name);
00046 
00047         bool user_is_moderator(const std::string& name);
00048         void set_is_moderator(const std::string& name, const bool& is_moderator);
00049 
00050         std::string user_info(const std::string& name);
00051 
00052         struct user {
00053             user() :
00054                     password(),
00055                     realname(),
00056                     mail(),
00057                     lastlogin(time(NULL)),
00058                     registrationdate(time(NULL)),
00059                     is_moderator(false) {}
00060             std::string password;
00061             std::string realname;
00062             std::string mail;
00063             time_t lastlogin;
00064             time_t registrationdate;
00065             bool is_moderator;
00066         };
00067 
00068         void set_user_detail(const std::string& user, const std::string& detail, const std::string& value);
00069         std::string get_valid_details();
00070 
00071         std::string create_pepper(const std::string&) { return ""; }
00072         bool use_phpbb_encryption() const { return false; }
00073 
00074     private:
00075         std::string get_mail(const std::string& user);
00076         std::string get_password(const std::string& user);
00077         std::string get_realname(const std::string& user) ;
00078         time_t get_lastlogin(const std::string& user);
00079         time_t get_registrationdate(const std::string& user);
00080 
00081         void check_name(const std::string& name);
00082         void check_mail(const std::string& mail);
00083         void check_password(const std::string& password);
00084         void check_realname(const std::string& realname);
00085 
00086         void set_mail(const std::string& user, const std::string& mail);
00087         void set_password(const std::string& user, const std::string& password);
00088         void set_realname(const std::string& user, const std::string& realname);
00089 
00090         void set_lastlogin(const std::string& user, const time_t& lastlogin);
00091 
00092         int user_expiration_;
00093 
00094         std::map <std::string,user> users_;
00095         std::vector<std::string> users();
00096 };
00097 
00098 #endif //SAMPLE_USER_HANDLER_HPP_INCLUDED
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated by doxygen 1.7.1 on Fri May 25 2012 01:03:10 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs