fixed: base_url_redirect config option was not read from the config file

and was not used when checking for base url redirect
fixed: return values from plugins should be given in a special structure
       they were remembered in plugin object (ret_false, ret_true)
       and consequently were not thread safe
       now all plugin.Call() methods return PluginRes structure 
       in which there are ret_false and ret_true variables       
changed: small refactoring in AddUser winix function



git-svn-id: svn://ttmath.org/publicrep/winix/trunk@827 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2012-04-22 13:30:07 +00:00
parent 920290e9dc
commit bcea4f9464
12 changed files with 165 additions and 119 deletions

View File

@@ -158,33 +158,40 @@ return false;
void AddUser::MakePost()
/*
adding a new account
this method doesn't check whether the login or password is correct
(consist of allowed characters)
input:
login - account login name
pass - password
email - email address
autoactivate - if true then the account will be created with WINIX_ACCOUNT_READY flag
(an email will not be sent)
if false then the flag depends on config->account_need_email_verification
try_login - if true then if there is no a user logged (in this session)
and if the account is ready (has WINIX_ACCOUNT_READY flag)
the the new user will be logged in
use_ses_log - when true the session logger will be used (info about sending an email)
*/
bool AddUser::AddNewUser(const std::wstring & login,
const std::wstring & pass,
const std::wstring & email,
bool autoactivate,
bool try_login,
bool use_ses_log)
{
user.Clear();
const std::wstring & login = cur->request->PostVar(L"login");
const std::wstring & pass = cur->request->PostVar(L"password");
const std::wstring & conf_pass = cur->request->PostVar(L"passwordconfirm");
const std::wstring & email = cur->request->PostVar(L"email");
long code = 0;
if( !IsLoginCorrect(login, true) || !IsEmailCorrect(email, true) ||
!functions->fun_passwd.IsPasswordCorrect(pass, conf_pass, true) )
return;
user.name = login;
user.email = email;
user.super_user = false;
user.notify = 0;
user.status = (config->account_need_email_verification)? WINIX_ACCOUNT_NOT_ACTIVATED : WINIX_ACCOUNT_READY;
long code = 0;
if( cur->session->puser && cur->session->puser->super_user )
{
if( cur->request->IsPostVar(L"autoactivate") )
{
user.status = WINIX_ACCOUNT_READY;
log << log2 << "AddUser: account activated by an admin" << logend;
}
}
if( autoactivate )
user.status = WINIX_ACCOUNT_READY;
if( user.status == WINIX_ACCOUNT_NOT_ACTIVATED )
{
@@ -194,7 +201,7 @@ void AddUser::MakePost()
if( AddNewUser(user, pass) )
{
if( !cur->session->puser && user.status == WINIX_ACCOUNT_READY )
if( try_login && !cur->session->puser && user.status == WINIX_ACCOUNT_READY )
{
system->users.LoginUser(user.id, false);
log << log2 << "AddUser: now logged as: " << user.name << logend;
@@ -204,11 +211,41 @@ void AddUser::MakePost()
if( user.status == WINIX_ACCOUNT_NOT_ACTIVATED )
{
system->notify.ActivateAccount(user.name, user.email, code);
slog << loginfo << T(L"account_email_sent") << logend;
if( use_ses_log )
slog << loginfo << T(L"account_email_sent") << logend;
}
system->RedirectToLastItem();
return true;
}
return false;
}
void AddUser::MakePost()
{
const std::wstring & login = cur->request->PostVar(L"login");
const std::wstring & pass = cur->request->PostVar(L"password");
const std::wstring & conf_pass = cur->request->PostVar(L"passwordconfirm");
const std::wstring & email = cur->request->PostVar(L"email");
bool autoactivate = false;
if( !IsLoginCorrect(login, true) ||
!IsEmailCorrect(email, true) ||
!functions->fun_passwd.IsPasswordCorrect(pass, conf_pass, true) )
return;
if( cur->session->puser && cur->session->puser->super_user )
{
autoactivate = cur->request->IsPostVar(L"autoactivate");
if( autoactivate )
log << log2 << "AddUser: account activated by an admin" << logend;
}
if( AddNewUser(login, pass, email, autoactivate, true, true) )
system->RedirectToLastItem();
}

View File

@@ -32,6 +32,13 @@ public:
bool HasLoginCorrectChars(const std::wstring & login);
bool AddNewUser(User & user, const std::wstring & pass);
bool AddNewUser(const std::wstring & login,
const std::wstring & pass,
const std::wstring & email,
bool autoactivate,
bool try_login,
bool use_ses_log = false);
private:
UserPass up;