Check for duplicate email addresses

This commit is contained in:
Al Beano 2017-07-18 13:51:30 +01:00
parent cdab16e9db
commit ecff4ac48e
4 changed files with 31 additions and 0 deletions

View File

@ -36,6 +36,19 @@ post '/account' => sub {
$errs{"e_no_email"} = 1;
}
if (param("email") ne $user->{"email"}) {
my $result = database->quick_select (
"user",
{
"email" => param("email"),
},
);
if ($result) {
$errs{"e_email_exists"} = 1;
}
}
if (param("password") || param("npassword") || param("npassword2")) {
$new_pass = 1;

View File

@ -17,6 +17,17 @@ post '/register' => sub {
}
}
my $result = database->quick_select(
"user",
{
"email" => param("email"),
},
);
if ($result) {
$errs{"e_email_exists"} = 1;
}
if (!exists $errs{"e_no_password"} || !exists $errs{"e_no_password2"}) {
if (param("password") ne param("password2")) {
$errs{"e_pass_match"} = 1;

View File

@ -28,9 +28,13 @@
<% IF e_pass_len %>
<li>Your password must be at least 8 characters long.</li>
<% END %>
<% IF e_email_exists %>
<li>There is already an account with that email address.</li>
<% END %>
</ul>
</div>
</div>
<br />
<% END %>
<div class="body">

View File

@ -25,6 +25,9 @@
<% IF e_pass_match %>
<li>The two passwords you entered do not match!</li>
<% END %>
<% IF e_email_exists %>
<li>There is already an account with that email address.</li>
<% END %>
</ul>
</div>
</div>