44
55use Darryldecode \Backend \Base \Controllers \BaseController ;
66
7+ use Illuminate \Contracts \Events \Dispatcher ;
78use Darryldecode \Backend \Components \User \Models \Throttle ;
89use Darryldecode \Backend \Components \User \Models \User ;
910use Darryldecode \Backend \Utility \Helpers ;
@@ -35,9 +36,10 @@ public function getLogin()
3536 * @param Request $request
3637 * @param Throttle $throttle
3738 * @param User $user
39+ * @param Dispatcher $dispatcher
3840 * @return $this|\Illuminate\Http\RedirectResponse
3941 */
40- public function postLogin (Request $ request , Throttle $ throttle , User $ user )
42+ public function postLogin (Request $ request , Throttle $ throttle , User $ user, Dispatcher $ dispatcher )
4143 {
4244 $ credentials = $ request ->only ('email ' , 'password ' );
4345
@@ -49,6 +51,8 @@ public function postLogin(Request $request, Throttle $throttle, User $user)
4951 // if authentication is good
5052 if ( $ result ->isSuccessful () )
5153 {
54+ $ dispatcher ->fire ('auth.loginSuccess ' , array ($ result ->getData ()));
55+
5256 if ( $ request ->get ('ru ' ) != '' )
5357 {
5458 return redirect ()->intended ($ request ->get ('ru ' ));
@@ -65,12 +69,15 @@ public function postLogin(Request $request, Throttle $throttle, User $user)
6569 /**
6670 * Log the user out of the application.
6771 *
72+ * @param Dispatcher $dispatcher
6873 * @return \Illuminate\Http\Response
6974 */
70- public function getLogout ()
75+ public function getLogout (Dispatcher $ dispatcher )
7176 {
7277 Auth::logout ();
7378
79+ $ dispatcher ->fire ('auth.logout ' );
80+
7481 return redirect (Helpers::getLoginRoute ());
7582 }
7683}
0 commit comments