fixed: misc: ValidateEmail() buffer overflow

added: notifications for resetting a user's password
       (there is no a winix function for this yet)



git-svn-id: svn://ttmath.org/publicrep/winix/trunk@817 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2012-03-09 22:56:54 +00:00
parent 489310ba1c
commit b7007da5a9
27 changed files with 540 additions and 145 deletions

View File

@@ -17,16 +17,11 @@
Notify::Notify()
{
}
void Notify::SetCur(Cur * pcur)
{
cur = pcur;
@@ -70,6 +65,7 @@ void Notify::Init()
notify_template_cms = AddTemplate(L"notify_email_cms.txt");
notify_template_activate_account = AddTemplate(L"notify_confirm_account.txt");
notify_template_reset_password = AddTemplate(L"notify_reset_password.txt");
plugin.Call(WINIX_NOTIFY_ADD_TEMPLATE);
}
@@ -124,6 +120,21 @@ void Notify::ActivateAccount(const std::wstring & name, const std::wstring & ema
}
void Notify::ResetPassword(const std::wstring & name, const std::wstring & email, long code)
{
msg.Clear();
msg.code = WINIX_NOTIFY_CODE_RESET_PASSWORD;
msg.name = name;
msg.email = email;
msg.lang = 0; // !! IMPROVE ME a better language can be chose
msg.activate_code = code;
msg.template_index = notify_template_reset_password;
CreateResetPasswordLink(name, code, msg.item_link);
notify_pool.Add(msg);
notify_thread.WakeUpThread(); // we are in the first locked thread
}
size_t Notify::AddTemplate(const std::wstring & file_name)
{
@@ -171,3 +182,16 @@ wchar_t buff[50];
Toa(code, buff, sizeof(buff)/sizeof(wchar_t));
link += buff;
}
void Notify::CreateResetPasswordLink(const std::wstring & name, long code, std::wstring & link)
{
wchar_t buff[50];
link = config->url_proto;
link += config->base_url;
link += L"/pw/resetpassword/login:";
UrlEncode(name, link, false);
link += L"/code:";
Toa(code, buff, sizeof(buff)/sizeof(wchar_t));
link += buff;
}

View File

@@ -45,6 +45,7 @@ public:
void ItemChanged(int notify_code, const Item & item);
void ItemChanged(const NotifyMsg & msg);
void ActivateAccount(const std::wstring & name, const std::wstring & email, long code);
void ResetPassword(const std::wstring & name, const std::wstring & email, long code);
private:
@@ -62,11 +63,13 @@ private:
size_t notify_template_cms;
size_t notify_template_activate_account;
size_t notify_template_reset_password;
Patterns patterns;
void CreateItemLink(const Item & item, std::wstring & link, std::wstring & dir_link);
void CreateActivateLink(const std::wstring & name, long code, std::wstring & link);
void CreateResetPasswordLink(const std::wstring & name, long code, std::wstring & link);
};

View File

@@ -20,6 +20,7 @@
#define WINIX_NOTIFY_CODE_DELETE 4
#define WINIX_NOTIFY_CODE_REPLY 8
#define WINIX_NOTIFY_CODE_CONFIRM_ACCOUNT 16
#define WINIX_NOTIFY_CODE_RESET_PASSWORD 32

View File

@@ -94,7 +94,8 @@ bool res = false;
TemplatesNotifyFunctions::notify_msg = notify_pool->GetFirst();
notify_pool->DeleteFirst();
if( TemplatesNotifyFunctions::notify_msg.code == WINIX_NOTIFY_CODE_CONFIRM_ACCOUNT )
if( TemplatesNotifyFunctions::notify_msg.code == WINIX_NOTIFY_CODE_CONFIRM_ACCOUNT ||
TemplatesNotifyFunctions::notify_msg.code == WINIX_NOTIFY_CODE_RESET_PASSWORD )
{
msg.email = TemplatesNotifyFunctions::notify_msg.email;
msg.name = TemplatesNotifyFunctions::notify_msg.name;