server/user_handler.cpp

Go to the documentation of this file.
00001 /* $Id: user_handler.cpp 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 #include "user_handler.hpp"
00017 #include "../config.hpp"
00018 #include "serialization/string_utils.hpp"
00019 
00020 #include <ctime>
00021 
00022 bool user_handler::send_mail(const std::string& to_user,
00023         const std::string& /*subject*/, const std::string& /*message*/) {
00024 
00025     //If this user is registerd at all
00026     if(!user_exists(to_user)) {
00027         throw error("Could not send email. No user with the name '" + to_user + "' exists.");
00028     }
00029 
00030     // If this user did not provide an email
00031     if(get_mail(to_user) == "") {
00032         throw error("Could not send email. The email address of the user '" + to_user + "' is empty.");
00033     }
00034 
00035     throw user_handler::error("This server is configured not to send email.");
00036 }
00037 
00038 void user_handler::init_mailer(const config &) {
00039 }
00040 
00041 std::string user_handler::create_salt(int length) {
00042     srand(static_cast<unsigned>(time(NULL)));
00043 
00044     std::stringstream ss;
00045 
00046     for(int i = 0; i < length; i++) {
00047         ss << (rand() % 10);
00048     }
00049 
00050     return  ss.str();
00051 }
 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