Skip to content

Commit a047903

Browse files
committed
show errors on login form fixed
1 parent 5aa174c commit a047903

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

src/Admin/src/Controller/AdminController.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ public function loginAction(): ResponseInterface
320320
);
321321
if ($identity->getStatus() === Admin::STATUS_INACTIVE) {
322322
$this->authenticationService->clearIdentity();
323-
$this->messenger->addError('Admin is inactive', 'user-login');
323+
$this->messenger->addError('Admin is inactive');
324324
$this->messenger->addData('shouldRebind', true);
325325
$this->forms->saveState($form);
326326
return new RedirectResponse($this->getRequest()->getUri(), 303);
@@ -336,13 +336,13 @@ public function loginAction(): ResponseInterface
336336
);
337337
$this->messenger->addData('shouldRebind', true);
338338
$this->forms->saveState($form);
339-
$this->messenger->addError($authResult->getMessages(), 'user-login');
339+
$this->messenger->addError($authResult->getMessages());
340340
return new RedirectResponse($this->getRequest()->getUri(), 303);
341341
}
342342
} else {
343343
$this->messenger->addData('shouldRebind', true);
344344
$this->forms->saveState($form);
345-
$this->messenger->addError($this->forms->getMessages($form), 'user-login');
345+
$this->messenger->addError($this->forms->getMessages($form));
346346
return new RedirectResponse($this->getRequest()->getUri(), 303);
347347
}
348348
}

src/Admin/src/Form/LoginForm.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ public function __construct(?string $name = null, array $options = [])
2525

2626
$this->init();
2727

28+
$this->setAttribute('id', 'login-form');
29+
$this->setAttribute('class', 'needs-validation');
30+
$this->setAttribute('novalidate', 'novalidate');
31+
2832
$this->inputFilter = new LoginInputFilter();
2933
$this->inputFilter->init();
3034
}
@@ -39,6 +43,7 @@ public function init(): void
3943
'attributes' => [
4044
'placeholder' => 'Username',
4145
'class' => 'form-control form-control-sm',
46+
'required' => 'required',
4247
],
4348
'type' => Text::class,
4449
]);
@@ -51,6 +56,7 @@ public function init(): void
5156
'attributes' => [
5257
'placeholder' => 'Password',
5358
'class' => 'form-control form-control-sm',
59+
'required' => 'required',
5460
],
5561
'type' => Password::class,
5662
]);

src/Admin/templates/admin/login.html.twig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<link href="{{ asset('css/app.css') }}" rel="stylesheet">
1515
</head>
1616
<body class="app">
17+
{{ messagesPartial('partial::notifications', {dismissible: true}) }}
1718
<div class="peers ai-s fxw-nw h-100vh align-items-center">
1819
<div class="container">
1920
<div class="row">
@@ -45,5 +46,9 @@
4546
</div>
4647
</div>
4748
</div>
49+
50+
{% block javascript %}
51+
<script src="{{ asset('js/app.js') }}"></script>
52+
{% endblock %}
4853
</body>
4954
</html>

0 commit comments

Comments
 (0)