* Confirm account from mail link
*
* @param Request $request The request
- * @param string $mail The shorted mail address
* @param string $hash The hashed password
+ * @param string $mail The shorted mail address
* @return Response The response
*/
- public function confirm(Request $request, $mail, $hash): Response {
+ public function confirm(Request $request, string $hash, string $mail): Response {
//With invalid hash
if ($hash != $this->slugger->hash($mail)) {
//Throw bad request
* Edit account by shorted mail
*
* @param Request $request The request
- * @param string $mail The shorted mail address
* @param string $hash The hashed password
+ * @param string $mail The shorted mail address
* @return Response The response
*/
- public function edit(Request $request, $mail, $hash): Response {
+ public function edit(Request $request, string $hash, string $mail): Response {
//With invalid hash
if ($hash != $this->slugger->hash($mail)) {
//Throw bad request
$data = $reset->getData();
//Set password
- $data->setPassword($this->hasher->encodePassword($data, $data->getPassword()));
+ $data->setPassword($this->hasher->hashPassword($data, $data->getPassword()));
//Queue snippet save
$this->manager->persist($data);
*
* @param Request $request The request
* @param AuthenticationUtils $authenticationUtils The authentication utils
- * @param string $mail The shorted mail address
- * @param string $hash The hashed password
+ * @param ?string $hash The hashed password
+ * @param ?string $mail The shorted mail address
* @return Response The response
*/
- public function login(Request $request, AuthenticationUtils $authenticationUtils, $mail, $hash): Response {
+ public function login(Request $request, AuthenticationUtils $authenticationUtils, ?string $hash, ?string $mail): Response {
//Create the LoginType form and give the proper parameters
$login = $this->createForm($this->config['login']['view']['form'], null, [
//Set action to login route name and context
* Recover account
*
* @param Request $request The request
- * @param string $mail The shorted mail address
- * @param string $pass The shorted password
- * @param string $hash The hashed password
+ * @param ?string $hash The hashed password
+ * @param ?string $pass The shorted password
+ * @param ?string $mail The shorted mail address
* @return Response The response
*/
- public function recover(Request $request, $mail, $pass, $hash): Response {
+ public function recover(Request $request, ?string $hash, ?string $pass, ?string $mail): Response {
//Without mail, pass and hash
if (empty($mail) && empty($pass) && empty($hash)) {
//Create the LoginType form and give the proper parameters
'method' => 'POST'
]);
+ //With post method
if ($request->isMethod('POST')) {
//Refill the fields in case the form is not valid.
$form->handleRequest($request);
- if ($form->isValid()) {
+ //With form submitted and valid
+ if ($form->isSubmitted() && $form->isValid()) {
//Set data
$data = $form->getData();
'method' => 'POST'
]);
+ //With post method
if ($request->isMethod('POST')) {
//Refill the fields in case the form is not valid.
$form->handleRequest($request);
- if ($form->isValid()) {
+ //With form submitted and valid
+ if ($form->isSubmitted() && $form->isValid()) {
//Set data
$data = $form->getData();
- //Set encoded password
- $encoded = $this->hasher->encodePassword($user, $user->getPassword());
+ //Set hashed password
+ $hashed = $this->hasher->hashPassword($user, $user->getPassword());
//Update pass
- $pass = $this->slugger->hash($encoded);
+ $pass = $this->slugger->hash($hashed);
//Set user password
- $user->setPassword($encoded);
+ $user->setPassword($hashed);
//Persist user
$this->manager->persist($user);
* Register an account
*
* @param Request $request The request
- * @param string $mail The shorted mail address
- * @param string $field The serialized then shorted form field array
- * @param string $hash The hashed serialized field array
+ * @param ?string $hash The hashed serialized field array
+ * @param ?string $field The serialized then shorted form field array
+ * @param ?string $mail The shorted mail address
* @return Response The response
*/
- public function register(Request $request, $mail, $field, $hash): Response {
+ public function register(Request $request, ?string $hash, ?string $field, ?string $mail): Response {
//With mail
if (!empty($_POST['register']['mail'])) {
//Log new user infos
'method' => 'POST'
]+$this->config['register']['field']);
+ //With post method
if ($request->isMethod('POST')) {
//Refill the fields in case the form is not valid.
$form->handleRequest($request);
- if ($form->isValid()) {
+ //With form submitted and valid
+ if ($form->isSubmitted() && $form->isValid()) {
//Set data
$data = $form->getData();
$registerMail =& $this->config['register']['mail'];
//Set password
- $user->setPassword($this->hasher->encodePassword($user, $user->getPassword()));
+ $user->setPassword($this->hasher->hashPassword($user, $user->getPassword()));
//Persist user
$this->manager->persist($user);