I am using laravel 5.4 as bankend for my application, And for front-end i am using angular. I am using laravel auth for authentication, Issue is Auth::attempt() is working fine and if immediately i print the Auth::user() then it will print the data but it return false if i try to fecth it in next method, But this functionality is is working fine in hosted server.
Tested,
- Changed session from file to database.
- Changes in kernel.php (Content of $middleware).
- Did php artisan make:auth one more time.
- Did changes in user table column.
- Added private $primarykey = 'id' to model.
- Added 'web' middleware to all routes.
This is my Controller
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Facades\Input;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use App\User;
public function login()
{
if (Auth::attempt(['email' => $email, 'password' => $password ,
'status' => $status]))
{
$response = array('response' =>'Succssfully Login!' , 'success' => true);
return $response;
}
}
This is where i am using Auth::check()
public function check()
{
if(Auth::check())
$response = array('response' =>'Authenticated' , 'success'=>true);
else
$response = array('response' =>'UnAuthenticated' , 'success'=>false);
return $response;
}
I am confuesd because same code is woking fine in hosted server but not wokking in local, Do i need to do any http realated cahnges in laravel for this ?.
Thank you.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire