Centralized demo account logic in the password auth service. ref #167

This commit is contained in:
emeric
2021-09-03 13:41:30 +02:00
parent a261484bb8
commit 7affe08fc4
15 changed files with 107 additions and 47 deletions
+15 -2
View File
@@ -559,11 +559,15 @@ handleChangePassword(RequestContext& context)
Service<Auth::IPasswordService>::get()->setPassword(context.dbSession, userId, password);
}
catch (Auth::PasswordTooWeakException&)
catch (const Auth::PasswordMustMatchLoginNameException&)
{
throw PasswordMustMatchLoginNameGenericError {};
}
catch (const Auth::PasswordTooWeakException&)
{
throw PasswordTooWeakGenericError {};
}
catch (Auth::Exception& authException)
catch (const Auth::Exception& authException)
{
throw UserNotAuthorizedError {};
}
@@ -658,6 +662,11 @@ handleCreateUserRequest(RequestContext& context)
{
Service<Auth::IPasswordService>::get()->setPassword(context.dbSession, userId, password);
}
catch (const Auth::PasswordMustMatchLoginNameException&)
{
removeCreatedUser();
throw PasswordMustMatchLoginNameGenericError {};
}
catch (const Auth::PasswordTooWeakException&)
{
removeCreatedUser();
@@ -1711,6 +1720,10 @@ handleUpdateUserRequest(RequestContext& context)
{
Service<::Auth::IPasswordService>()->setPassword(context.dbSession, userId, decodePasswordIfNeeded(*password));
}
catch (const Auth::PasswordMustMatchLoginNameException&)
{
throw PasswordMustMatchLoginNameGenericError {};
}
catch (const Auth::PasswordTooWeakException&)
{
throw PasswordTooWeakGenericError {};