user9465677
user9465677

Reputation: 427

Laravel - Can no longer use basic auth

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

Kernel file

enter image description here

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

Upvotes: 0

Views: 342

Answers (1)

Dhiraj
Dhiraj

Reputation: 2767

Everything looks fine, except to useTymon\JWTAuth you should make these changes

Change the api driver to jwt instead of token, I would have posted the code if you would have posted the code instead of an image and change the default guard to be api.

And for your basic auth you should be able to use it without a problem. Try doing it, if you could not post the code and I'll post the code.

Upvotes: 0

Related Questions