feat: distinguish error and info feedbacks
This commit is contained in:
@@ -13,13 +13,8 @@ class Notification
|
|||||||
public ?int $code;
|
public ?int $code;
|
||||||
public ?string $message;
|
public ?string $message;
|
||||||
|
|
||||||
public function isSuccessful(): bool
|
public function isError(): bool
|
||||||
{
|
{
|
||||||
// Successful responses don't carry codes and messages
|
return 650 !== $this->code;
|
||||||
if (null === $this->code && null === $this->message) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 650 === $this->code && false === stripos($this->message, 'fehler');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,9 +94,13 @@ class EditController extends AbstractController
|
|||||||
'email' => $bpnUser->getEmail(),
|
'email' => $bpnUser->getEmail(),
|
||||||
'booking_id' => $id,
|
'booking_id' => $id,
|
||||||
]);
|
]);
|
||||||
if ($response instanceof Notification && false === $response->isSuccessful()) {
|
if ($response instanceof Notification) {
|
||||||
$this->addFlash('error', $response->message);
|
if (true === $response->isError()) {
|
||||||
$this->logger->error('Error initiating booking update', [
|
$this->addFlash('error', $response->message);
|
||||||
|
} else {
|
||||||
|
$this->addFlash('info', $response->message);
|
||||||
|
}
|
||||||
|
$this->logger->error('Booking update not successful', [
|
||||||
'email' => $bpnUser->getEmail(),
|
'email' => $bpnUser->getEmail(),
|
||||||
'booking_id' => $id,
|
'booking_id' => $id,
|
||||||
'message' => $response->message,
|
'message' => $response->message,
|
||||||
|
|||||||
@@ -34,10 +34,10 @@ class RegistrationController extends AbstractController
|
|||||||
if ($form->isSubmitted() && $form->isValid()) {
|
if ($form->isSubmitted() && $form->isValid()) {
|
||||||
try {
|
try {
|
||||||
$response = $this->apiClient->register($registrationData);
|
$response = $this->apiClient->register($registrationData);
|
||||||
if ($response->isSuccessful()) {
|
if (true === $response->isError()) {
|
||||||
$this->addFlash('success', 'Du erhältst in Kürze eine E-Mail mit einem Link zum (Zurück)setzen deines Passworts.');
|
|
||||||
} else {
|
|
||||||
$this->addFlash('error', 'Möglicherweise bist du bereits registriert. Bitte setze dein Passwort zurück.');
|
$this->addFlash('error', 'Möglicherweise bist du bereits registriert. Bitte setze dein Passwort zurück.');
|
||||||
|
} else {
|
||||||
|
$this->addFlash('success', 'Du erhältst in Kürze eine E-Mail mit einem Link zum (Zurück)setzen deines Passworts.');
|
||||||
}
|
}
|
||||||
$this->logger->info('Initiated registration', [
|
$this->logger->info('Initiated registration', [
|
||||||
'email' => $registrationData->email,
|
'email' => $registrationData->email,
|
||||||
@@ -57,4 +57,4 @@ class RegistrationController extends AbstractController
|
|||||||
'form' => $form->createView(),
|
'form' => $form->createView(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user