jeudi 29 mars 2018

Laravel 5.4 Auth::check() returning false

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,

  1. Changed session from file to database.
  2. Changes in kernel.php (Content of $middleware).
  3. Did php artisan make:auth one more time.
  4. Did changes in user table column.
  5. Added private $primarykey = 'id' to model.
  6. 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.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2GSNm0H
via IFTTT

Aucun commentaire:

Enregistrer un commentaire