Add register and login of authentification actions #12
Merged
samuel.berion
merged 22 commits from connexion/bootstrap
into master
1 year ago
Loading…
Reference in new issue
There is no content yet.
Delete Branch 'connexion/bootstrap'
Deleting a branch is permanent. It CANNOT be undone. Continue?
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
"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
$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
return ViewHttpResponse::twig("display_login.html.twig", []);
}
public function displayLoginPassed(array $request):HttpResponse{
it's not used, and is not complete. remove it
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.$errors = [];
if ($password != $confirmPassword) {
$errors[] = new FieldValidationFail("confirmpassword","passwords not equals");
}
public function validationLogin(string $email,string $password): array{
same here, rename this
login
<!DOCTYPE html>
remove this file
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 namedconfirmLogin
.]);
$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 thefails
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
.2207bb8af0
to7685ff8454
1 year ago9333288705
into master 1 year agoReviewers
9333288705
.