doufei8691 2017-01-26 14:24 采纳率: 100%
浏览 81
已采纳

为什么我尝试使用自定义用户提供程序登录时出现“Class App \ Listeners \ LogAuthenticationAttempt不存在”错误?

I am pretty new in PHP and Laravel framework and I am going crazy trying to implement the following task.

I am trying to follow this tutorial to implement a custom user provider:

https://blog.georgebuckingham.com/laravel-52-auth-custom-user-providers-drivers/

I am using Larave 5.3 version.

I briefly expain what I need: my Laravel application is only a front end application, all the business logic, included the user authentication, is performed by a Java back end application that exposes REST web services.

Performing a call to:

http://localhost:8080/Extranet/login

and passing username and password as basic authentication I obtain a JSON response like this that represent the logged user:

{
  "userName": "Painkiller",
  "email": "painkiller@gmail.com",
  "enabled": true
}

So, in my Laravel application, I have to perform this call and then parse the previous returned JSON object to generate the authenticated object into the front end application session.

I think that the previous custom user provider is the neater and most natural solution to do it, but I am obtaining an erro, I will explain the situation.

I have implemented all the 4 steps of the previous tutorial and I think that I have correctly replaced the user provider with my custom user provider.

Aftere these implementation steps I performed this command:

php artisan make:auth

to generate te view and the routes related to the Laravel login system. I expect that it is using the custom user provider defined by me.

So I have these routes:

$ php artisan route:list
+--------+----------+------------------------+----------+------------------------------------------------------------------------+--------------+
| Domain | Method   | URI                    | Name     | Action                                                                 | Middleware   |
+--------+----------+------------------------+----------+------------------------------------------------------------------------+--------------+
|        | GET|HEAD | /                      |          | App\Http\Controllers\LoginBetriviusController@index                    | web          |
|        | GET|HEAD | api/user               |          | Closure                                                                | api,auth:api |
|        | POST     | doLogin                |          | App\Http\Controllers\LoginBetriviusController@doLogin                  | web          |
|        | GET|HEAD | home                   |          | App\Http\Controllers\HomeController@index                              | web,auth     |
|        | POST     | login                  |          | App\Http\Controllers\Auth\LoginController@login                        | web,guest    |
|        | GET|HEAD | login                  | login    | App\Http\Controllers\Auth\LoginController@showLoginForm                | web,guest    |
|        | POST     | logout                 | logout   | App\Http\Controllers\Auth\LoginController@logout                       | web          |
|        | POST     | password/email         |          | App\Http\Controllers\Auth\ForgotPasswordController@sendResetLinkEmail  | web,guest    |
|        | GET|HEAD | password/reset         |          | App\Http\Controllers\Auth\ForgotPasswordController@showLinkRequestForm | web,guest    |
|        | POST     | password/reset         |          | App\Http\Controllers\Auth\ResetPasswordController@reset                | web,guest    |
|        | GET|HEAD | password/reset/{token} |          | App\Http\Controllers\Auth\ResetPasswordController@showResetForm        | web,guest    |
|        | GET|HEAD | register               | register | App\Http\Controllers\Auth\RegisterController@showRegistrationForm      | web,guest    |
|        | POST     | register               |          | App\Http\Controllers\Auth\RegisterController@register                  | web,guest    |
+--------+----------+------------------------+----------+------------------------------------------------------------------------+--------------+

As you can see there are the standard login routes. I think that now it have to use my custom user provider (the one that call my REST web service) instead the standard one.

I run the application using the statment:

php artisan serve

It starts without no error, then I access to this URL:

http://localhost:8000/login

and the login page is correctly displayed.

Then i insert the credential (e-mail and password) but when I submit the login form I obtain this error message:

ReflectionException in Container.php line 749:
Class App\Listeners\LogAuthenticationAttempt does not exist
in Container.php line 749
at ReflectionClass->__construct('App\Listeners\LogAuthenticationAttempt') in Container.php line 749
at Container->build('App\Listeners\LogAuthenticationAttempt', array()) in Container.php line 644
at Container->make('App\Listeners\LogAuthenticationAttempt', array()) in Application.php line 709
at Application->make('App\Listeners\LogAuthenticationAttempt') in Dispatcher.php line 373
at Dispatcher->createClassCallable('App\Listeners\LogAuthenticationAttempt', object(Application)) in Dispatcher.php line 354
at Dispatcher->Illuminate\Events\{closure}(object(Attempting))
at call_user_func_array(object(Closure), array(object(Attempting))) in Dispatcher.php line 221
at Dispatcher->fire(object(Attempting)) in SessionGuard.php line 401
at SessionGuard->fireAttemptEvent(array('email' => 'dsfsdf@sdfsdf.com', 'password' => 'fdsfsdfsdf'), true, true) in SessionGuard.php line 351
at SessionGuard->attempt(array('email' => 'dsfsdf@sdfsdf.com', 'password' => 'fdsfsdfsdf'), true) in AuthenticatesUsers.php line 77
at LoginController->attemptLogin(object(Request)) in AuthenticatesUsers.php line 42
at LoginController->login(object(Request))
at call_user_func_array(array(object(LoginController), 'login'), array(object(Request))) in Controller.php line 55
at Controller->callAction('login', array(object(Request))) in ControllerDispatcher.php line 44
at ControllerDispatcher->dispatch(object(Route), object(LoginController), 'login') in Route.php line 190
at Route->runController() in Route.php line 144
at Route->run(object(Request)) in Router.php line 653
at Router->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in RedirectIfAuthenticated.php line 24
at RedirectIfAuthenticated->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in SubstituteBindings.php line 41
at SubstituteBindings->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in VerifyCsrfToken.php line 65
at VerifyCsrfToken->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in ShareErrorsFromSession.php line 49
at ShareErrorsFromSession->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in StartSession.php line 64
at StartSession->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in EncryptCookies.php line 59
at EncryptCookies->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 104
at Pipeline->then(object(Closure)) in Router.php line 655
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 629
at Router->dispatchToRoute(object(Request)) in Router.php line 607
at Router->dispatch(object(Request)) in Kernel.php line 268
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 46
at CheckForMaintenanceMode->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 104
at Pipeline->then(object(Closure)) in Kernel.php line 150
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 117
at Kernel->handle(object(Request)) in index.php line 54
at require_once('C:\Users\Andrea\Documents\Betrivius\WorkSpace\betriviusExtranet\public\index.php') in server.php line 21

Why? What could be wrong? How can I try to ix this issue?

I am not into Laravel but searching online information about Laravel login and the problem to the missing LogAuthenticationAttempt class I have fount this SO post:

Log failed login attempts with Laravel 5.2

Maybe it is a similar problem but I am not understanding it it could be the same situation and how to solve it.

What can I do?

  • 写回答

1条回答 默认 最新

  • doutangtan6386 2017-01-26 15:29
    关注

    Try running the command php artisan event:generate and it will generate any events in the $listen variable in your EventServiceProvider.php file.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
  • ¥15 linux驱动,linux应用,多线程