The Laravel 5.4 Auth facade does not work. The auth middleware functional normally. A call to a protected route produces the login page, as expected. Malformed credentials produce the expected error. Correct credentials produce the correct page, as expected. Commenting out the line "use Illuminate\Support\Facades\Auth;" produces the error "Class 'App\Http\Controllers\Admin\Auth' not found", as expected.
Specifically, Auth::check() produces false, and Auth::user() returns nothing, in spite of a successful login. Calls to either of these implementations of the Auth facade does not produce an error.
This code worked well in Laravel 5.2. The only deviation from procedure of which I am aware is that during the migration to Laravel 5.4, I did not run the command "php artisan make:auth" in a new Laravel implementation.
A search for "laravel 5.4 auth facade does not work" does not produce relevant results, either in Bing or in the stackoverflow internal search engine.
Pertinent code is displayed, below:
namespace App\Http\Controllers\Admin;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\User;
use App\Models\Admin;
use App\Models\Role;
use App\Models\Role_user;
use App\Models\Client;
use App\Models\Contact;
use App\Models\PublicPages;
use App\Models\Survey_question;
use App\Models\Survey_item;
use App\Models\Survey_project;
use App\Models\State;
use App\Models\Test_post;
use App\Models\Registration;
use Hash;
use Redirect;
use DB;
use Illuminate\Support\Facades\Auth;
use App\Classes\RoleHelper;
use App\Classes\CommonCode;
class AdminController extends Controller
{
var $obj_logged_in_user;
var $arr_logged_in_user;
var $bool_has_role;
var $roleHelper;
//organization of function
// 1. __construct
// 2. index
// get, alphabetically
// post, alphabetically
public function __construct(
Role_user $role_user, RoleHelper $roleHelper, Request
$request)
{
$this->middleware('auth');
echo "<pre>";
echo "admin controller, line 50<br>";
print_r($request->user);
echo "</pre>";
// line 49 (request->user) produces nothing
if (Auth::check())
{
$this->middleware('role:admin');
$this->obj_logged_in_user = Auth::user();
print_r($this->obj_logged_in_user);
// line 58 (print_r) produces nothing
$this->arr_logged_in_user = $roleHelper->prepare_logged_in_user_info($this->obj_logged_in_user);
} // end if Auth::check()
} // end __construct function
In conclusion, I would like for Auth::check() to return accurate results, and for Auth::user() to return the logged in user object. Thank you in advance.