[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 { .form-group {
all: unset;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
margin-bottom: 10px;
}
.form-group label {
margin-bottom: 5px;
} }
.help-block { .help-block {
margin-top: 5px; margin-top: 5px;
margin-bottom: 10px; margin-bottom: 10px;
@ -500,6 +499,8 @@ summary:hover .icon-details-open {
.help-block > .list-unstyled, .help-block > .list-unstyled,
.alert, .alert,
.alert-danger { .alert-danger {
display: inline-block;
border: solid 2px #FF6347; border: solid 2px #FF6347;
background-color: #FF634733; background-color: #FF634733;
border-radius: var(--unit-size); 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]]); $user = DB::findOneBy('local_user', ['or' => ['nickname' => $nick, 'outgoing_email' => $nick]]);
} catch (Exception $e) { } catch (Exception $e) {
throw new CustomUserMessageAuthenticationException( throw new CustomUserMessageAuthenticationException(
_m('\'{nickname}\' doesn\'t match any registered nickname or email.', ['nickname' => $credentials['nickname']])); _m('Invalid login credentials.'));
} }
return $user; 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> <legend class="section-form-legend">{{ "Login" | trans }}</legend>
{% if error %} {% if error %}
<label class="alert alert-danger">
{{ error.getMessage() }}
</label>
<ul> {#<ul>
{% for flashError in app.flashes('verify_email_error') %} {% for flashError in app.flashes('verify_email_error') %}
<li class="alert alert-danger">{{ error.messageKey | trans(error.messageData, 'security') }}</li> <li class="alert alert-danger">{{ error.messageKey | trans(error.messageData, 'security') }}</li>
{% endfor %} {% endfor %}
</ul> </ul>#}
{% endif %} {% endif %}

View File

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