From: Maxim Mamontov Date: Thu, 18 Sep 2014 19:43:34 +0000 (+0300) Subject: Added a function to check user existance. X-Git-Url: https://git.stg.codes/stg.git/commitdiff_plain/8738549c84637f1250749a212cc05d55c746fc03 Added a function to check user existance. --- diff --git a/include/stg/users.h b/include/stg/users.h index 9f516aef..3fb951e0 100644 --- a/include/stg/users.h +++ b/include/stg/users.h @@ -33,6 +33,7 @@ public: virtual ~USERS() {} virtual int FindByName(const std::string & login, USER_PTR * user) = 0; virtual int FindByName(const std::string & login, CONST_USER_PTR * user) const = 0; + virtual bool Exists(const std::string & login) const = 0; virtual bool TariffInUse(const std::string & tariffName) const = 0; diff --git a/projects/stargazer/users_impl.cpp b/projects/stargazer/users_impl.cpp index d66456af..3dd7638b 100644 --- a/projects/stargazer/users_impl.cpp +++ b/projects/stargazer/users_impl.cpp @@ -126,6 +126,13 @@ if (FindByNameNonLock(login, &u)) return 0; } //----------------------------------------------------------------------------- +bool USERS_IMPL::Exists(const std::string & login) const +{ +STG_LOCKER lock(&mutex); +const std::map::const_iterator iter(loginIndex.find(login)); +return iter != loginIndex.end(); +} +//----------------------------------------------------------------------------- bool USERS_IMPL::TariffInUse(const std::string & tariffName) const { STG_LOCKER lock(&mutex); diff --git a/projects/stargazer/users_impl.h b/projects/stargazer/users_impl.h index 43065bde..a8f8d559 100644 --- a/projects/stargazer/users_impl.h +++ b/projects/stargazer/users_impl.h @@ -77,6 +77,8 @@ public: int FindByName(const std::string & login, USER_PTR * user); int FindByName(const std::string & login, CONST_USER_PTR * user) const; + bool Exists(const std::string & login) const; + bool TariffInUse(const std::string & tariffName) const; void AddNotifierUserAdd(NOTIFIER_BASE *);