part II of rewriting

git-svn-id: svn://ttmath.org/publicrep/winix/trunk@635 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2010-08-12 19:10:12 +00:00
parent c3fac2e83f
commit 9a199cd834
38 changed files with 1159 additions and 1167 deletions

View File

@@ -21,33 +21,27 @@ AddUser::AddUser()
}
bool AddUser::CheckAddUserVars(const std::string * login, const std::string * pass, const std::string * conf_pass)
bool AddUser::CheckAddUserVars(const std::string & login, const std::string & pass, const std::string & conf_pass)
{
if( !login || !pass || !conf_pass )
{
request->status = WINIX_ERR_PERMISSION_DENIED;
return false;
}
if( login->empty() )
if( login.empty() )
{
request->status = WINIX_ERR_LOGIN_EMPTY;
return false;
}
if( *pass != *conf_pass )
if( pass != conf_pass )
{
request->status = WINIX_ERR_PASSWORDS_DIFFERENT;
return false;
}
if( pass->size() < 5 )
if( pass.size() < config->password_min_size )
{
request->status = WINIX_ERR_PASSWORD_TOO_SHORT;
return false;
}
if( system->users.IsUser(*login) )
if( system->users.IsUser(login) )
{
request->status = WINIX_ERR_USER_EXISTS;
return false;
@@ -65,20 +59,17 @@ void AddUser::MakePost()
{
User user;
std::string * login = request->PostVar("login");
std::string * pass = request->PostVar("password");
std::string * conf_pass = request->PostVar("confirmpassword");
std::string * email = request->PostVar("email");
const std::string & login = request->PostVar("login");
const std::string & pass = request->PostVar("password");
const std::string & conf_pass = request->PostVar("confirmpassword");
if( !CheckAddUserVars(login, pass, conf_pass) )
return;
user.name = *login;
user.name = login;
user.email = request->PostVar("email");
if( email )
user.email = *email;
request->status = db->AddUser(user, *pass);
request->status = db->AddUser(user, pass);
if( request->status == WINIX_ERR_OK )
{
@@ -87,11 +78,11 @@ User user;
if( !request->session->puser )
system->users.LoginUser(user.id, false);
log << log2 << "Content: added a new user: " << user.name << logend;
log << log2 << "Adduser: added a new user: " << user.name << logend;
}
else
{
log << log1 << "Content: I can't add to system->users: " << user.name
log << log1 << "Adduser: I can't add to system->users: " << user.name
<< " but the user was added to the db correctly" << logend;
}