so I have an ajax call to a contoller which is logging me in, I know this is working because of Auth::check($user)
and the returned cookie data, such as the laravel session cookie.
However, my problem is in my routes.php
, I still can't get to the authorized only pages, and keep hitting the welcome
view.
My routes.php:
use App\punsmodel;
use Illuminate\Http\Request;
if (Auth::guest()) {
Route::get('/', function () {
return view('welcome');
});
} else {
Route::group(['middleware' => 'auth'], function () {
Route::get('/', function () {
return view('mainview');
});
Route::get('mainview', function () {
return view('mainviewMolly');
});
});
}
My controller:
<?php
namespace App\Http\Controllers;
use App\Email;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Google_Client;
use Auth;
use App\User;
class verify extends Controller
{
public function verifyIdToken(Request $request)
{
$user = User::where('name', 'Molly')->first();
Auth::login($user);
if (Auth::check($user))
{
return response()->json(['Logged In' => "Yes!"]);
}
}
}
So I do an ajax request to the above controller, which works as I get the json response that says I was logged in, however then when I refresh the homepage, I still get the welcome page not the mainview
. Why is this the case?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire