-
|
I have something like this: try {
$currentAction = $fints->login();
$currentAction->ensureDone();
if ($currentAction instanceof DialogInitialization) {
$currentAction = $work;
$fints->execute($currentAction);
$currentAction->ensureDone();
}
} catch (TanRequiredException|ActionPendingException|VopConfirmationRequiredException $e) {
return $this->handleFinTsInterruptionException(...);
} catch (ServerException $e) {
return $this->informUserOfError(...);
} finally {
//storeToSession();
}
$fints->close();
//storeToSession();This stores FinTs to the session no matter what. Using the state from the session works fine when dealing with VoP and TAN. The problem comes when reusing the persisted state for the next action/Geschäftsvorfall. How would I check if I need to login again? As the user can close the browser at any time, |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
|
We could add That said, I think you should be in control of whether the session is active or not. So whenever you "exercise that control", i.e. change the state of the session, you could flip an auxiliary bit in the same database where you also store the persisted instance. Though I see the convenience of using
In such a scenario, in order to be properly in control, you should either (a) run some cron job that closes connections that haven't been used for x minutes, or (b) upon resume assume that sessions unused for more than x minutes are gone (and call A problem with both of these approaches would be figuring out the "x minutes". One solution could be to define the number of minutes yourself (and tell your users about it, e.g. you can then even display an auto-logout timer on your UI) and in order to make it the truth, you have a higher-frequency cron job that sends keep-alive messages for any sessions that it assumes are still active (and haven't sent a message within the last minute anyway), until your defined timeout is reached, at which point the cron job actively closes the session. Keep-alive is defined in Another solution would be to assume "x" is |
Beta Was this translation helpful? Give feedback.
-
|
For anyone interested, this is my current solution. The only downside is if you send a lot of data with your action, it will might be sent twice. This could be solved with the Keep-Alive-Message discussed above. class FinTsSessionAware extends FinTs
{
public function storeToSession(): void
{
// Implement this yourself
}
public function hasDialog(): bool
{
return $this->dialogId !== null;
}
public function loginIfNeededAndExecute(BaseAction $action): BaseAction
{
$logger = $this->getLogger();
$loginNeeded = false;
if ($this->hasDialog()) {
// Probieren ob wir vlt noch eingeloggt sind
$currentAction = $action;
try {
$logger->info('Executing ' . get_class($currentAction));
$this->execute($currentAction);
} catch (ServerException $e) {
if ($e->hasError(Rueckmeldungscode::ABGEBROCHEN)) {
$loginNeeded = true;
} else {
// Something else went wrong.
throw $e;
}
}
} else {
$loginNeeded = true;
}
if ($loginNeeded) {
$logger->info('Calling login()');
$currentAction = $this->login();
$currentAction->ensureDone();
// Login ist erfolgt, also eigentliche Action ausführen
if ($currentAction instanceof DialogInitialization) {
$currentAction = $action;
$logger->info('Executing ' . get_class($currentAction));
$this->execute($currentAction);
}
}
return $currentAction;
}
} |
Beta Was this translation helpful? Give feedback.
For anyone interested, this is my current solution.
The only downside is if you send a lot of data with your action, it will might be sent twice. This could be solved with the Keep-Alive-Message discussed above.