summaryrefslogtreecommitdiffstats
path: root/src/Common/UserManager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Common/UserManager.cpp')
-rw-r--r--src/Common/UserManager.cpp43
1 files changed, 39 insertions, 4 deletions
diff --git a/src/Common/UserManager.cpp b/src/Common/UserManager.cpp
index bb4d205..d04a644 100644
--- a/src/Common/UserManager.cpp
+++ b/src/Common/UserManager.cpp
@@ -203,10 +203,6 @@ boost::shared_ptr<const std::multimap<unsigned long, unsigned long> > UserManage
return dbBackend->getFullUserGroupList(timestamp);
}
-void UserManager::setPassword(unsigned long /*uid*/, const std::string& /*password*/) throw(Core::Exception) {
- throw Core::Exception(Core::Exception::NOT_AVAILABLE);
-}
-
void UserManager::checkUserInfo(const UserInfo &userInfo) throw(Core::Exception) {
boost::shared_lock<boost::shared_mutex> lock(mutex);
@@ -422,5 +418,44 @@ void UserManager::deleteUserFromGroup(unsigned long uid, unsigned long gid) thro
}
}
+void UserManager::setPassword(unsigned long uid, const std::string &password) throw(Core::Exception) {
+ boost::lock_guard<boost::shared_mutex> lock(mutex);
+
+ if(!dbBackend)
+ throw Core::Exception(Core::Exception::NOT_AVAILABLE);
+
+ boost::shared_ptr<const UserInfo> userInfo = dbBackend->getUserInfo(uid, 0);
+ if(!userInfo)
+ throw Core::Exception(Core::Exception::NOT_FOUND);
+
+ bool ok = false;
+ Core::Exception exception;
+
+ try {
+ dbBackend->setPassword(uid, password);
+ ok = true;
+ }
+ catch(Core::Exception e) {
+ exception = e;
+
+ if(e.getErrorCode() != Core::Exception::NOT_IMPLEMENTED)
+ application->log(Core::LoggerBase::USER, Core::LoggerBase::WARNING, e.strerror());
+ }
+
+ for(std::set<boost::shared_ptr<UserConfigBackend> >::iterator configBackend = configBackends.begin(); configBackend != configBackends.end(); ++configBackend) {
+ try {
+ (*configBackend)->setPassword(*userInfo, password);
+ ok = true;
+ }
+ catch(Core::Exception e) {
+ if(e.getErrorCode() != Core::Exception::NOT_IMPLEMENTED)
+ application->log(Core::LoggerBase::USER, Core::LoggerBase::WARNING, e.strerror());
+ }
+ }
+
+ if(!ok)
+ throw exception;
+}
+
}
}