Add register and login of authentification actions #12

Merged
samuel.berion merged 22 commits from connexion/bootstrap into master 1 year ago
Owner
There is no content yet.
samuel.berion added 16 commits 1 year ago
maxime.batista requested changes 1 year ago
maxime.batista left a comment

nice

nice
$fails = [];
$request = HttpRequest::from($request, $fails, [
"username" => [Validators::name(), Validators::lenBetween(0, 32)],
"password" => [Validators::lenBetween(0, 256)],

you should force the password to be greater than 6 chars

you should force the password to be greater than 6 chars
samuel.berion marked this conversation as resolved
"username" => [Validators::name(), Validators::lenBetween(0, 32)],
"password" => [Validators::lenBetween(0, 256)],
"confirmpassword" => [Validators::lenBetween(0, 256)],
"email" => [Validators::regex("/@/")]

you should look for a more valid mail validation regex, because barion@ satisfies the regex validator but is not a valid mail.

Also, always set a max length for user inputs. Because the user could have a 4gb email address

you should look for a more valid mail validation regex, because `barion@` satisfies the regex validator but is not a valid mail. Also, always set a max length for user inputs. Because the user could have a 4gb email address
samuel.berion marked this conversation as resolved
$bad_fields[] = $err->getFieldName();
}
}
return ViewHttpResponse::twig("display_register.html.twig", ['bad_fields' => $bad_fields]);
+ $bad_fields = [];
+ foreach ($fails as $err) {
+     if ($err instanceof FieldValidationFail) {
+         $bad_fields[] = $err->getFieldName();
+     }
+ }
+ return ViewHttpResponse::twig("display_register.html.twig", ['bad_fields' => $bad_fields]);

You are using this fragment of code 3 times, you can factorise it inside a function

```diff + $bad_fields = []; + foreach ($fails as $err) { + if ($err instanceof FieldValidationFail) { + $bad_fields[] = $err->getFieldName(); + } + } + return ViewHttpResponse::twig("display_register.html.twig", ['bad_fields' => $bad_fields]); ``` You are using this fragment of code 3 times, you can factorise it inside a function
samuel.berion marked this conversation as resolved
return ViewHttpResponse::twig("display_login.html.twig", []);
}
public function displayLoginPassed(array $request):HttpResponse{

it's not used, and is not complete. remove it

it's not used, and is not complete. remove it
Poster
Owner

uh... you can read my entire code before leaving such poorly thought out comments, I'm stunned! :)))

uh... you can read my entire code before leaving such poorly thought out comments, I'm stunned! :)))
}
public function validationRegister(string $username, string $password, string $confirmPassword,string $email): array {

Rename this function with register, as it does more than only validate the account registration, it registers it.

Rename this function with `register`, as it does more than only validate the account registration, it registers it.
samuel.berion marked this conversation as resolved
$errors = [];
if ($password != $confirmPassword) {
$errors[] = new FieldValidationFail("confirmpassword","passwords not equals");
- password not equals
+ password and password confirmation are not equals
```diff - password not equals + password and password confirmation are not equals ```
samuel.berion marked this conversation as resolved
}
public function validationLogin(string $email,string $password): array{

same here, rename this login

same here, rename this `login`
samuel.berion marked this conversation as resolved
<!DOCTYPE html>

remove this file

remove this file
samuel.berion marked this conversation as resolved
samuel.berion added 1 commit 1 year ago
continuous-integration/drone/push Build is passing Details
eb37915b00
correction for pr
samuel.berion added 1 commit 1 year ago
continuous-integration/drone/push Build is passing Details
ff77f2fb89
apply suggestions
maxime.batista requested changes 1 year ago
maxime.batista left a comment

you did not remove the file Views/display_error_validation_register.html.twig.

you did not remove the file `Views/display_error_validation_register.html.twig`.
return ViewHttpResponse::twig("display_login.html.twig", []);
}
public function displayLoginPassed(array $request):HttpResponse{

please name your methods uniformly
This method does the same thing as confirmRegister, but for login, so the method should be named confirmLogin.

please name your methods uniformly This method does the same thing as `confirmRegister`, but for login, so the method should be named `confirmLogin`.
samuel.berion marked this conversation as resolved
]);
$fails = $this->model->login($request['email'],$request['password']);

You forgot here to test if the HttpRequest::from added failures to the fails array.
If the user's input does not match your given request schema, the returned request object is null, and the failures are appended to the fails array.

Try to login with an invalid password, or an invalid email, you'll get an error involving $request['email'] because $request is null, as the user's request did not validated the schema.

Simply add a check before this line, like you did in validateRegister.

You forgot here to test if the HttpRequest::from added failures to the `fails` array. If the user's input does not match your given request schema, the returned `request` object is null, and the failures are appended to the `fails` array. Try to login with an invalid password, or an invalid email, you'll get an error involving `$request['email']` because `$request` is null, as the user's request did not validated the schema. Simply add a check before this line, like you did in `validateRegister`.
samuel.berion marked this conversation as resolved
samuel.berion force-pushed connexion/bootstrap from 2207bb8af0 to 7685ff8454 1 year ago
samuel.berion added 1 commit 1 year ago
continuous-integration/drone/push Build is passing Details
df929e7458
conception
samuel.berion added 2 commits 1 year ago
samuel.berion merged commit 9333288705 into master 1 year ago
samuel.berion deleted branch connexion/bootstrap 1 year ago

Reviewers

maxime.batista requested changes 1 year ago
continuous-integration/drone/push Build is passing
The pull request has been merged as 9333288705.
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date

No due date set.

Dependencies

No dependencies set.

Reference: IQBall/Application-Web#12
Loading…
There is no content yet.