Skip to content
This repository was archived by the owner on Apr 19, 2025. It is now read-only.

Commit d638400

Browse files
authored
Update README.md
1 parent 4074961 commit d638400

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,24 @@ class TwoFactorAuthController extends Controller
156156
protected $redirectTo = '/home';
157157
}
158158
```
159+
3 If you want to give textual feedback to the user when two-factor authentication fails due to an expired token or when throttling kicks in you may want to add this to `resources/views/auth/login.blade.php`:
160+
```php
161+
...
162+
<form class="form-horizontal" role="form" method="POST" action="{{ route('login') }}">
163+
{{ csrf_field() }}
164+
165+
{{-- Add this block to show an error message in case of an expired token or user lockout --}}
166+
@if ($errors->has('token'))
167+
<div class="form-group has-error">
168+
<div class="col-xs-12">
169+
<span class="help-block">
170+
<strong>{{ $errors->first('token') }}</strong>
171+
</span>
172+
</div>
173+
</div>
174+
@endif
175+
...
176+
```
159177

160178
## Errors and Exceptions
161179
Unfortunately the *MessageBird* php api throws rather generic exceptions when the verification of a token fails. The only way to distinguish an expired token from an invalid token is by comparing their error messages, which obviously is not a very robust mechanism. The reason this is rather unfortunate is because in the case of an invalid token we want to give the user at least a few (3) changes to re-enter the token before throttling kicks in, whereas in the case of an expired token we just want to redirect to the login screen right away.

0 commit comments

Comments
 (0)