I used the article below to create JWT auth in my laravel project. But now I can no longer use the Basic auth. Is there a way to use Basic auth as well? I need it for my web interface.
https://scotch.io/tutorials/token-based-authentication-for-angularjs-and-laravel-apps
namespace App\Http\Controllers\Auth;
use App\User;
use Validator;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\ThrottlesLogins;
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
class AuthController extends Controller
{
use AuthenticatesAndRegistersUsers, ThrottlesLogins;
public function __construct()
{
$this->middleware('guest', ['except' => 'getLogout']);
}
protected function validator(array $data)
{
return Validator::make($data, [
'name' => 'required|max:255',
'email' => 'required|email|max:255|unique:users',
'password' => 'required|confirmed|min:6',
]);
}
protected function create(array $data)
{
return User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => bcrypt($data['password']),
]);
}
}
Route::get('auth/login', 'Auth\AuthController@getLogin'); Route::post('auth/login', 'Auth\AuthController@postLogin');
Update: after turning the debug on I got the following error:
Symfony \ Component \ Debug \ Exception \ FatalErrorException (E_UNKNOWN) Trait 'Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers' not found
kernel.php
try posting your kernel file – Dhirajauth.php
file, and also post your controller where you are trying to use the basic auth – Dhiraj