diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/AuthenticationManagementService.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/AuthenticationManagementService.cpp index 27be89f..71d66b6 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/AuthenticationManagementService.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/services/AuthenticationManagementService.cpp @@ -79,15 +79,15 @@ void AuthenticationManagementService::changePassword(const std::string& newPassw { DataStoreLockGuard lock(m_dataStore); auto& trackedUsersMap = m_dataStore.getUsers(); + if (m_authenticatedUser == nullptr) + { + throw std::runtime_error("There is no user currently logged in!"); + } int index = trackedUsersMap.find(m_authenticatedUser->getId()); if (index == -1) { throw std::runtime_error("User does not exist!\n"); } - if (m_authenticatedUser == nullptr) - { - throw std::runtime_error("There is no user currently logged in!"); - } m_authenticatedUser->setPassword(newPassword); trackedUsersMap.getValueAt(index).state = RecordState::MODIFIED; m_dataStore.saveUsers();