fix: do not use cur if login winix function if config.use_internal_loggin_mechanism is false

In the login winix function cur pointer will be null if config.use_internal_loggin_mechanism
is false, in such a case those objects are not registered as winix functions
but we have a public api
(the public api should be moved somewhere e.g. make a service layer)
This commit is contained in:
Tomasz Sowa 2022-07-27 01:25:49 +02:00
parent 9e6a5b2d37
commit e5ed1d6ae8
2 changed files with 26 additions and 1 deletions

View File

@ -113,6 +113,9 @@ bool Login::CheckUserPass(const std::wstring & login, const std::wstring & passw
{
bool result;
if( !cur )
return false;
morm::Finder<User> finder(model_connector);
User user = finder.
@ -186,6 +189,9 @@ void Login::CheckBan()
bool Login::ShouldUseCaptchaForCurrentIP()
{
if( !cur )
return false;
if( cur->session->ip_ban )
return ShouldUseCaptchaFor(*cur->session->ip_ban);
@ -195,6 +201,9 @@ return false;
bool Login::ShouldUseCaptchaFor(const IPBan & ipban)
{
if( !cur )
return false;
if( ipban.expires != 0 && cur->request->start_time >= ipban.expires )
return false; // the 'ip block' has expired (but incorrect_login_events has the old value)
@ -204,6 +213,9 @@ return ipban.incorrect_login_events >= config->incorrect_login_captcha_treshold;
bool Login::CannotLoginFromCurrentIP()
{
if( !cur )
return false;
if( cur->session->ip_ban )
return CannotLoginFrom(*cur->session->ip_ban);
@ -213,6 +225,9 @@ return false;
bool Login::CannotLoginFrom(const IPBan & ipban)
{
if( !cur )
return false;
if( ipban.IsIPBanned() )
return true;
@ -260,6 +275,9 @@ bool Login::LoginUser(const std::wstring & login, const std::wstring & password,
{
long user_id;
if( !cur )
return false;
if( cur->session->id == 0 )
{
log << log2 << "Login: can't login in a temporary session (skipped)" << logend;

View File

@ -45,7 +45,14 @@ namespace Winix
namespace Fun
{
/*
* WARNING
* cur will be null if config.use_internal_loggin_mechanism is false
* in such a case those objects are not registered as winix functions
* but we have a public api
* (the public api should be moved somewhere e.g. make a service layer)
*
*/
class Login : public FunctionBase
{
public: