[Security][Exception] Security exception handling, login and register. TODO EmailNotFoundException and NicknameNotFoundException.

This commit is contained in:
Eliseu Amaro 2021-09-15 14:47:29 +01:00
parent 26af284353
commit e9d809d441
6 changed files with 34 additions and 15 deletions

View File

@ -480,13 +480,12 @@ summary:hover .icon-details-open {
}
.form-group {
all: unset;
display: flex;
flex-direction: column;
margin-bottom: 10px;
}
.form-group label {
margin-bottom: 5px;
}
.help-block {
margin-top: 5px;
margin-bottom: 10px;
@ -500,6 +499,8 @@ summary:hover .icon-details-open {
.help-block > .list-unstyled,
.alert,
.alert-danger {
display: inline-block;
border: solid 2px #FF6347;
background-color: #FF634733;
border-radius: var(--unit-size);

View File

@ -97,7 +97,7 @@ class Authenticator extends AbstractFormLoginAuthenticator
$user = DB::findOneBy('local_user', ['or' => ['nickname' => $nick, 'outgoing_email' => $nick]]);
} catch (Exception $e) {
throw new CustomUserMessageAuthenticationException(
_m('\'{nickname}\' doesn\'t match any registered nickname or email.', ['nickname' => $credentials['nickname']]));
_m('Invalid login credentials.'));
}
return $user;

View File

@ -0,0 +1,7 @@
<?php
namespace App\Util\Exception;
class EmailNotFoundException extends EmailException {
// TODO: everything
}

View File

@ -0,0 +1,9 @@
<?php
namespace App\Util\Exception;
use App\Util\Exception\NicknameException;
class NicknameNotFoundException extends NicknameException {
// TODO: everything
}

View File

@ -14,12 +14,15 @@
<legend class="section-form-legend">{{ "Login" | trans }}</legend>
{% if error %}
<label class="alert alert-danger">
{{ error.getMessage() }}
</label>
<ul>
{#<ul>
{% for flashError in app.flashes('verify_email_error') %}
<li class="alert alert-danger">{{ error.messageKey | trans(error.messageData, 'security') }}</li>
{% endfor %}
</ul>
</ul>#}
{% endif %}

View File

@ -15,14 +15,13 @@
<fieldset>
<legend class="section-form-legend">{{ "Register" | trans }}</legend>
<ul>
{% for flashError in app.flashes('verify_email_error') %}
<li class="alert alert-danger" role="alert">{{ flashError }}</li>
<label class="alert alert-danger" role="alert">{{ flashError }}</label>
{% endfor %}
{% for flashError in app.flashes('verify_nickname_error') %}
<li class="alert alert-danger" role="alert">{{ flashError }}</li>
<label class="alert alert-danger" role="alert">{{ flashError }}</label>
{% endfor %}
</ul>
{{ form_row(registration_form.nickname) }}
{{ form_row(registration_form.email) }}