Skip to content

Commit 649421f

Browse files
committed
Fix Registration
Fix bug on Registration.
1 parent 1423350 commit 649421f

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

src/Controller/RegistrationController.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,17 +96,19 @@ public function register(Request $request): Response
9696
$this->autoLoginUser($user);
9797

9898
return $this->redirectToRoute('home');
99-
}else{
99+
} else {
100100
$this->addFlash('error', $this->translator->trans('Vérifiez vos informations, code d\'erreur : R001'));
101101
}
102-
}else{
102+
} else {
103103
$this->addFlash('error', $this->translator->trans('Vérifiez vos informations, code d\'erreur : R002'));
104104
}
105-
}else{
106-
$this->addFlash('error', $this->translator->trans('Vérifiez vos informations, code d\'erreur : R003'));
105+
} else {
106+
if ($form->isSubmitted() && !$form->isValid()) {
107+
$this->addFlash('error', $this->translator->trans('Vérifiez vos informations, code d\'erreur : R003'));
108+
}
107109
}
108110

109-
return $this->render('Application/' .$this->settings->get('theme') . '/registration/register.html.twig', [
111+
return $this->render('Application/' . $this->settings->get('theme') . '/registration/register.html.twig', [
110112
'registrationForm' => $form->createView(),
111113
]);
112114
}
@@ -116,7 +118,7 @@ private function isUserUnique(string $username, string $email): bool
116118
$userInfos = $this->api->getUser($username);
117119
$userEmailExist = $this->userRepo->findOneBy(['email' => $email]);
118120

119-
return isset($userInfos['Message']) && $userInfos['Message'] == "No user with name '$username'." && !$userEmailExist;
121+
return isset($userInfos['Message']) && $userInfos['Message'] == "Not Found" && !$userEmailExist;
120122
}
121123

122124
private function autoLoginUser(User $user): void

src/Settings/Api.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ public function APIcall_POST(string $server, array $postData, string $access_tok
9393
$response = '{"Message": "Authorization has been denied for this request."}';
9494
}
9595

96+
if($httpcode == 404) {
97+
$response = '{"Message": "Not Found"}';
98+
}
99+
96100
$responseData = json_decode($response, true);
97101
curl_close($ch);
98102

0 commit comments

Comments
 (0)