Refactor session flow management for captcha and password.
This commit is contained in:
parent
23262bc0a6
commit
1108711eb7
2 changed files with 4 additions and 30 deletions
|
@ -50,27 +50,15 @@
|
||||||
|
|
||||||
// Remove the SET_PASSWORD flag
|
// Remove the SET_PASSWORD flag
|
||||||
SessionManager::removeFlags($request->getSessionUuid(), [SessionFlags::SET_PASSWORD]);
|
SessionManager::removeFlags($request->getSessionUuid(), [SessionFlags::SET_PASSWORD]);
|
||||||
|
|
||||||
|
// Check & update the session flow
|
||||||
|
SessionManager::updateFlow($request->getSession());
|
||||||
}
|
}
|
||||||
catch(Exception $e)
|
catch(Exception $e)
|
||||||
{
|
{
|
||||||
throw new StandardException('Failed to set password due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e);
|
throw new StandardException('Failed to set password due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if all registration flags are removed
|
|
||||||
if(SessionFlags::isComplete($request->getSession()->getFlags()))
|
|
||||||
{
|
|
||||||
// Set the session as authenticated
|
|
||||||
try
|
|
||||||
{
|
|
||||||
SessionManager::setAuthenticated($request->getSessionUuid(), true);
|
|
||||||
SessionManager::removeFlags($request->getSessionUuid(), [SessionFlags::REGISTRATION_REQUIRED, SessionFlags::AUTHENTICATION_REQUIRED]);
|
|
||||||
}
|
|
||||||
catch (DatabaseOperationException $e)
|
|
||||||
{
|
|
||||||
throw new StandardException('Failed to update session due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $rpcRequest->produceResponse(true);
|
return $rpcRequest->produceResponse(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -47,6 +47,7 @@
|
||||||
if($result)
|
if($result)
|
||||||
{
|
{
|
||||||
SessionManager::removeFlags($request->getSessionUuid(), [SessionFlags::VER_IMAGE_CAPTCHA]);
|
SessionManager::removeFlags($request->getSessionUuid(), [SessionFlags::VER_IMAGE_CAPTCHA]);
|
||||||
|
SessionManager::updateFlow($session);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (DatabaseOperationException $e)
|
catch (DatabaseOperationException $e)
|
||||||
|
@ -54,21 +55,6 @@
|
||||||
throw new StandardException("There was an unexpected error while trying to answer the captcha", StandardError::INTERNAL_SERVER_ERROR, $e);
|
throw new StandardException("There was an unexpected error while trying to answer the captcha", StandardError::INTERNAL_SERVER_ERROR, $e);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if all registration flags are removed
|
|
||||||
if(SessionFlags::isComplete($request->getSession()->getFlags()))
|
|
||||||
{
|
|
||||||
// Set the session as authenticated
|
|
||||||
try
|
|
||||||
{
|
|
||||||
SessionManager::setAuthenticated($request->getSessionUuid(), true);
|
|
||||||
SessionManager::removeFlags($request->getSessionUuid(), [SessionFlags::REGISTRATION_REQUIRED, SessionFlags::AUTHENTICATION_REQUIRED]);
|
|
||||||
}
|
|
||||||
catch (DatabaseOperationException $e)
|
|
||||||
{
|
|
||||||
return $rpcRequest->produceError(StandardError::INTERNAL_SERVER_ERROR, $e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $rpcRequest->produceResponse($result);
|
return $rpcRequest->produceResponse($result);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue