X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/f7163d9c994af13f0f72f49f7203b7ac3e281a1e..e2e4e44c53dd035edad67fc7d6941dff48dccbd4:/projects/stargazer/plugins/authorization/ao/ao.cpp?ds=sidebyside diff --git a/projects/stargazer/plugins/authorization/ao/ao.cpp b/projects/stargazer/plugins/authorization/ao/ao.cpp index 004210d2..cef272c0 100644 --- a/projects/stargazer/plugins/authorization/ao/ao.cpp +++ b/projects/stargazer/plugins/authorization/ao/ao.cpp @@ -27,6 +27,7 @@ $Author: faust $ #include #include +#include #include // for_each #include // mem_fun_ref @@ -69,8 +70,15 @@ return "Always Online authorizator v.1.0"; } //----------------------------------------------------------------------------- AUTH_AO::AUTH_AO() - : users(NULL), + : errorStr(), + users(NULL), + usersList(), isRunning(false), + settings(), + BeforeChgAONotifierList(), + AfterChgAONotifierList(), + BeforeChgIPNotifierList(), + AfterChgIPNotifierList(), onAddUserNotifier(*this), onDelUserNotifier(*this) { @@ -104,7 +112,8 @@ list::iterator users_iter; users_iter = usersList.begin(); while (users_iter != usersList.end()) { - Unauthorize(*users_iter); + if ((*users_iter)->IsAuthorizedBy(this)) + users->Unauthorize((*users_iter)->GetLogin(), this); UnSetUserNotifiers(*users_iter); ++users_iter; } @@ -200,11 +209,7 @@ void AUTH_AO::GetUsers() { USER_PTR u; int h = users->OpenSearch(); -if (!h) - { - printfd(__FILE__, "users->OpenSearch() error\n"); - return; - } +assert(h && "USERS::OpenSearch is always correct"); while (!users->SearchNext(h, &u)) { @@ -215,21 +220,14 @@ while (!users->SearchNext(h, &u)) users->CloseSearch(h); } //----------------------------------------------------------------------------- -void AUTH_AO::Unauthorize(USER_PTR u) const -{ -u->Unauthorize(this); -} -//----------------------------------------------------------------------------- -void AUTH_AO::UpdateUserAuthorization(USER_PTR u) const +void AUTH_AO::UpdateUserAuthorization(CONST_USER_PTR u) const { if (u->GetProperty().alwaysOnline) { USER_IPS ips = u->GetProperty().ips; if (ips.OnlyOneIP()) { - if (u->Authorize(ips[0].ip, 0xFFffFFff, this) == 0) - { - } + users->Authorize(u->GetLogin(), ips[0].ip, 0xFFffFFff, this); } } } @@ -243,7 +241,7 @@ UpdateUserAuthorization(u); //----------------------------------------------------------------------------- void AUTH_AO::DelUser(USER_PTR u) { -Unauthorize(u); +users->Unauthorize(u->GetLogin(), this); UnSetUserNotifiers(u); usersList.remove(u); } @@ -258,7 +256,8 @@ template void CHG_BEFORE_NOTIFIER::Notify(const varParamType &, const varParamType &) { //EVENT_LOOP_SINGLETON::GetInstance().Enqueue(auth, &AUTH_AO::Unauthorize, user); -auth.Unauthorize(user); +if (user->IsAuthorizedBy(&auth)) + auth.users->Unauthorize(user->GetLogin(), &auth); } //----------------------------------------------------------------------------- template