I have upgraded my project from 5.2 to 5.3 in laravel. after that, I have the following error:-
Trait method hasTooManyLoginAttempts has not been applied, because there are collisions with other trait methods on App\Http\Controllers\Auth\AuthController in D:\xampp1\htdocs\clubmart_frontend\ app\Http\Controllers\Auth\AuthController.php on line 19
Following is the code of my AuthController:-
<?php
namespace App\Http\Controllers\Auth;
use App\Contracts\Repositories\UserRepositoryInterface;
use App\Http\Controllers\Controller;
use App\Models\User;
use App\Models\Voucher;
use App\Services\CartManager;
use Illuminate\Foundation\Auth\RegistersUsers;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
use Illuminate\Foundation\Auth\ThrottlesLogins;
use Validator;
use Illuminate\Http\Request;
use App\Events\UserWasRegistered;
use Event;
use Auth;
class AuthController extends Controller
{
/*
|--------------------------------------------------------------------------
| Registration & Login Controller
|--------------------------------------------------------------------------
|
| This controller handles the registration of new users, as well as the
| authentication of existing users. By default, this controller uses
| a simple trait to add these behaviors. Why don't you explore it?
|
*/
use AuthenticatesUsers, RegistersUsers {
AuthenticatesUsers::redirectPath insteadof RegistersUsers;
AuthenticatesUsers::guard insteadof RegistersUsers;
}
use ThrottlesLogins;
public $guard = 'web';
/**
* Where to redirect users after login / registration.
*
* @var string
*/
protected $redirectTo = '/';
/** @var UserRepositoryInterface */
protected $userRepository;
/**
* Create a new authentication controller instance.
*
* @param UserRepositoryInterface $userRepository
*/
public function __construct(UserRepositoryInterface $userRepository)
{
$this->userRepository = $userRepository;
$this->middleware($this->guestMiddleware(), ['except' => 'logout']);
}
/**
* Get a validator for an incoming registration request.
*
* @param array $data
*
* @return Validator
*/
protected function validator(array $data)
{
return Validator::make(
$data,
[
'first_name' => 'required|max:255',
'last_name' => 'required|max:255',
'email' => 'required|email|max:255|unique:users',
'password' => 'required|min:6|confirmed',
]
);
}
/**
* Create a new user instance after a valid registration.
*
* @param array $data
*
* @return User
*/
protected function create(array $data)
{
return $this->userRepository->create(
[
'name' => $data['email'],
'first_name' => $data['first_name'],
'last_name' => $data['last_name'],
'email' => $data['email'],
'password' => $data['password'],
]
);
}
protected function authenticated(Request $request, User $user)
{
if($user = Auth::user()) {
if(!empty(app(CartManager::class)->getItems())) {
return redirect()->intended('/cart');
}
else {
return redirect()->intended('/');
}
}
else {
return redirect()->intended('/');
}
}
//overwrite for add flash message to session
public function postRegister(Request $request, User $user)
{
$validator = $this->validator($request->all());
if ($validator->fails()) {
$this->throwValidationException(
$request, $validator
);
}
//login the newly created user
\Auth::login($this->create($request->all()));
//fire up the send user email event
$user_id = $user->find(\Auth::user()->id);
Event::fire(new UserWasRegistered($user_id));
$request->session()->flash('alert-success', 'Registration successful!');
if(!empty(app(CartManager::class)->getItems())) {
return redirect()->intended('/cart');
}
else {
return redirect($this->redirectPath());
}
}
/**
* Log the user out of the application.
* overwrite for clear user from session
* @return \Illuminate\Http\Response
*/
public function logout(Request $request)
{
if($request->session()->has('user_id'))
$request->session()->forget('user_id');
\Auth::guard($this->getGuard())->logout();
return redirect(property_exists($this, 'redirectAfterLogout') ? $this->redirectAfterLogout : '/');
}
}
This is the code of Controller.php:-
<?php
namespace App\Http\Controllers;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
// use Illuminate\Foundation\Auth\Access\AuthorizesResources;
class Controller extends BaseController
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
}
Any help will be appreciated. thanks in advance.
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/362W8oT
via IFTTT
Aucun commentaire:
Enregistrer un commentaire