Route
Route::post('/AuthenticateUser',
array(
'uses' => 'API\Auth\apiLoginController@AuthenticateUser',
'as' => 'AuthenticateUser',
'middleware' => ['throttle: 6,1']
)
);
Controller Action Method
class apiLoginController extends Controller
{
use ThrottlesLogins;
public function AuthenticateUser(LoginRequest $request) {
//If request fails then calling `$this->TotalAttemptsLeft($request)`
'Message' => "Invalid credentials" . $this->TotalAttemptsLeft($request)
. " attempts left.",
}
}
Details about the issue
ThrottlesLogins
class present here :
vendor\laravel\framework\src\Illuminate\Foundation\Auth\ThrottlesLogins.php
has a function called throttleKey
which uses username and IP address for the key whereas ThrottleRequests
class which is present here:
\vendor\laravel\framework\src\Illuminate\Routing\Middleware\ThrottleRequests.php
uses $request->fingerprint();
function to get key
What's the problem?
In the controller action method above: I am unable to get total attempts left using method TotalAttemptsLeft
in ThrottlesLogins
class.
Question?
Is there any way if I could use ThrottleRequests class in my controller to get remaining attempts? or please suggest any appropriate way
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire