What do you mean by with/without the token ?
May 11, 2015
4
Level 4
Auth remember_me token does not work
Hi, I'm trying to use the remember_me feature to allow users to authenticate using the token. Everything works fine when I select the checkbox:
- login with token
- close browser without logging out
- go to website - still logged in - OK!!
Everything also works fine when manually logging out
- login with token
- manually log out
- close browser
- go to website - not logged in - OK!!
The problem is when I log in without the token. For some reason, the use is still authenticated, even after I close the browser.
- login without token
- close browser without logging out
- go to website - still logged in - NOT OK!!
I'm using the default Laravel implementation, nothing special there. So that makes me wonder - is this normal behavior? Or am I not doing something here?
<?php namespace App\Http\Controllers\Auth;
use Illuminate\Contracts\Auth\Guard;
use Illuminate\Contracts\Auth\Registrar;
use Ixudra\Core\Http\Controllers\BaseController;
use App\Http\Requests\Auth\LoginFormRequest;
use App;
class AuthController extends BaseController {
public function __construct(Guard $auth, Registrar $registrar, AuthViewFactory $authViewFactory)
{
$this->auth = $auth;
$this->registrar = $registrar;
$this->authViewFactory = $authViewFactory;
}
public function processLogin(LoginFormRequest $request)
{
if( $this->auth->attempt( $request->only('email', 'password'), $request->getInput()['remember'] ) ) {
$redirect = 'index';
if( $this->auth->user()->isAdmin() ) {
$redirect = 'admin.index';
}
return $this->redirect($redirect, array(), 'success', array(trans('authentication.login.success')));
}
return $this->redirect('login', array(), 'error', array(trans('authentication.login.dataIncorrect')));
}
public function logout()
{
$this->auth->logout();
return $this->redirect('index', array(), 'success', array(trans('authentication.logout.success')));
}
}
Please or to participate in this conversation.