Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
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& , const std::string& ) {
00024
00025
00026 if(!user_exists(to_user)) {
00027 throw error("Could not send email. No user with the name '" + to_user + "' exists.");
00028 }
00029
00030
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 }