Split auth service in two services

This commit is contained in:
emeric
2019-07-30 13:17:25 +02:00
parent d114c763c3
commit 40000249c6
12 changed files with 363 additions and 235 deletions
+3 -3
View File
@@ -23,7 +23,7 @@
#include <Wt/WLineEdit.h>
#include <Wt/WPushButton.h>
#include "auth/AuthService.hpp"
#include "auth/PasswordService.hpp"
#include "main/Service.hpp"
#include "utils/Exception.hpp"
#include "utils/Logger.hpp"
@@ -55,7 +55,7 @@ class InitWizardModel : public Wt::WFormModel
void saveData()
{
const Database::User::PasswordHash passwordHash {getService<::Auth::AuthService>()->hashPassword(valueText(PasswordField).toUTF8())};
const Database::User::PasswordHash passwordHash {getService<::Auth::PasswordService>()->hashPassword(valueText(PasswordField).toUTF8())};
auto transaction(LmsApp->getDbSession().createUniqueTransaction());
@@ -77,7 +77,7 @@ class InitWizardModel : public Wt::WFormModel
if (!valueText(PasswordField).empty())
{
// Evaluate the strength of the password
if (!getService<::Auth::AuthService>()->evaluatePasswordStrength(valueText(AdminLoginField).toUTF8(), valueText(PasswordField).toUTF8()))
if (!getService<::Auth::PasswordService>()->evaluatePasswordStrength(valueText(AdminLoginField).toUTF8(), valueText(PasswordField).toUTF8()))
error = Wt::WString::tr("Lms.password-too-weak");
}
else
+3 -3
View File
@@ -28,7 +28,7 @@
#include <Wt/WFormModel.h>
#include "auth/AuthService.hpp"
#include "auth/PasswordService.hpp"
#include "database/User.hpp"
#include "main/Service.hpp"
#include "utils/Config.hpp"
@@ -82,7 +82,7 @@ class UserModel : public Wt::WFormModel
{
boost::optional<Database::User::PasswordHash> passwordHash;
if (!valueText(PasswordField).empty())
passwordHash = getService<::Auth::AuthService>()->hashPassword(valueText(PasswordField).toUTF8());
passwordHash = getService<::Auth::PasswordService>()->hashPassword(valueText(PasswordField).toUTF8());
auto transaction {LmsApp->getDbSession().createUniqueTransaction()};
@@ -172,7 +172,7 @@ class UserModel : public Wt::WFormModel
else
{
// Evaluate the strength of the password for non demo accounts
if (!getService<::Auth::AuthService>()->evaluatePasswordStrength(getLoginName(), valueText(PasswordField).toUTF8()))
if (!getService<::Auth::PasswordService>()->evaluatePasswordStrength(getLoginName(), valueText(PasswordField).toUTF8()))
error = Wt::WString::tr("Lms.password-too-weak");
}
}