WIP: remove the old database abstraction layer

remove such classes:
- DbBase
- DbConn
- DbTextStream
- Db

while here:
- remove: TextStream, SLog, TexTextStream
This commit is contained in:
2024-06-22 18:03:54 +02:00
parent 5d457f3d4b
commit 6aa100f12c
138 changed files with 6658 additions and 12402 deletions

View File

@@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2011-2021, Tomasz Sowa
* Copyright (c) 2011-2024, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -33,7 +33,7 @@
*/
#include "passwd.h"
#include "core/slog.h"
#include "core/misc.h"
#include "functions/functions.h"
@@ -62,14 +62,14 @@ bool Passwd::HasAccess()
bool Passwd::IsPasswordCorrect(const std::wstring & pass, const std::wstring & conf_pass, bool use_ses_log)
bool Passwd::IsPasswordCorrect(const std::wstring & pass, const std::wstring & conf_pass)
{
if( pass != conf_pass )
{
log << log2 << "Passwd: passwords are different" << logend;
if( use_ses_log )
slog << logerror << T("adduser_err_passwords_different") << logend;
// if( use_ses_log )
// slog << logerror << T("adduser_err_passwords_different") << logend;
return false;
}
@@ -78,9 +78,9 @@ bool Passwd::IsPasswordCorrect(const std::wstring & pass, const std::wstring & c
{
log << log2 << "Passwd: password is too small" << logend;
if( use_ses_log )
slog << logerror << T("adduser_err_password_too_small") << " "
<< config->pass_min_size << " " << T("adduser_err_password_too_small2") << logend;
// if( use_ses_log )
// slog << logerror << T("adduser_err_password_too_small") << " "
// << config->pass_min_size << " " << T("adduser_err_password_too_small2") << logend;
return false;
}
@@ -89,9 +89,9 @@ bool Passwd::IsPasswordCorrect(const std::wstring & pass, const std::wstring & c
{
log << log2 << "Passwd: password can't be longer than: " << WINIX_ACCOUNT_MAX_PASSWORD_SIZE << " characters" << logend;
if( use_ses_log )
slog << logerror << T("adduser_err_password_too_big") << " " << WINIX_ACCOUNT_MAX_PASSWORD_SIZE
<< " " << T("adduser_err_password_too_big2") << logend;
// if( use_ses_log )
// slog << logerror << T("adduser_err_password_too_big") << " " << WINIX_ACCOUNT_MAX_PASSWORD_SIZE
// << " " << T("adduser_err_password_too_big2") << logend;
return false;
}
@@ -143,16 +143,16 @@ long user_id;
if( !cur->session->puser->is_super_user && !functions->fun_login.CheckUserPass(puser->login, pass_cur, user_id) )
{
log << log3 << "Passwd: incorrect current password" << logend;
slog << logerror << T("passwd_err_bad_current_password") << logend;
//slog << logerror << T("passwd_err_bad_current_password") << logend;
return;
}
if( !IsPasswordCorrect(pass_new, pass_conf, true) )
if( !IsPasswordCorrect(pass_new, pass_conf) )
return;
if( ChangePassword(puser->id, pass_new) )
{
slog << loginfo << T("passwd_password_changed") << logend;
//slog << loginfo << T("passwd_password_changed") << logend;
system->RedirectToLastItem();
}
}
@@ -160,26 +160,26 @@ long user_id;
bool Passwd::SetNewPassword(User * puser, bool use_ses_log)
bool Passwd::SetNewPassword(User * puser)
{
bool result = false;
const std::wstring & pass = cur->request->PostVar(L"passwordnew");
const std::wstring & pass_conf = cur->request->PostVar(L"passwordconfirm");
if( IsPasswordCorrect(pass, pass_conf, use_ses_log) )
if( IsPasswordCorrect(pass, pass_conf) )
{
if( ChangePassword(puser->id, pass) )
{
result = true;
if( use_ses_log )
slog << loginfo << T("pw_password_changed") << logend;
// if( use_ses_log )
// slog << loginfo << T("pw_password_changed") << logend;
}
else
{
if( use_ses_log )
slog << logerror << T("service_unavailable") << logend;
// if( use_ses_log )
// slog << logerror << T("service_unavailable") << logend;
}
}
@@ -188,7 +188,7 @@ return result;
bool Passwd::ResetPassword(User * puser, long code, bool use_ses_log, bool only_check_access)
bool Passwd::ResetPassword(User * puser, long code, bool only_check_access)
{
std::wstring * user_code_str = puser->admin_env.get_wstr(L"password_change_code");
@@ -199,29 +199,29 @@ bool Passwd::ResetPassword(User * puser, long code, bool use_ses_log, bool only_
if( only_check_access )
return true;
else
return SetNewPassword(puser, use_ses_log);
return SetNewPassword(puser);
}
else
{
log << log2 << "Passwd: incorrect change password code" << logend;
if( use_ses_log )
slog << logerror << T(L"incorrect_change_password_code") << logend;
// if( use_ses_log )
// slog << logerror << T(L"incorrect_change_password_code") << logend;
}
}
else
{
log << log1 << "Passwd: there is no change password code in admin environment" << logend;
if( use_ses_log )
slog << loginfo << T(L"password_cannot_be_changed") << logend;
// if( use_ses_log )
// slog << loginfo << T(L"password_cannot_be_changed") << logend;
}
return false;
}
bool Passwd::ResetPassword(const std::wstring & login, long code, bool use_ses_log, bool only_check_access)
bool Passwd::ResetPassword(const std::wstring & login, long code, bool only_check_access)
{
bool result = false;
User * puser = system->users.GetUser(login);
@@ -232,14 +232,14 @@ bool Passwd::ResetPassword(const std::wstring & login, long code, bool use_ses_l
if( puser->admin_env.to_long(L"password_change_time") + config->reset_password_code_expiration_time > t )
{
result = ResetPassword(puser, code, use_ses_log, only_check_access);
result = ResetPassword(puser, code, only_check_access);
}
else
{
log << log2 << "Passwd: the code has expired" << logend;
if( use_ses_log )
slog << logerror << T(L"code_expired") << logend;
// if( use_ses_log )
// slog << logerror << T(L"code_expired") << logend;
}
}
else
@@ -256,7 +256,7 @@ void Passwd::ResetPassword()
const std::wstring & login = cur->request->PostVar(L"login");
long code = Tol(cur->request->PostVar(L"code"));
if( ResetPassword(login, code, true, false) )
if( ResetPassword(login, code, false) )
system->RedirectToLastItem();
}
@@ -268,7 +268,7 @@ void Passwd::ShowResetPasswordForm()
if( !login.empty() )
{
if( !ResetPassword(login, code, true, true) )
if( !ResetPassword(login, code, true) )
system->RedirectToLastItem();
}
else