Domanda

I have a problem. When I try to log in to my app, I get following message:

ErrorException

Array to string conversion

Backtrace:

/(insignificant)/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php

$dbDataCol = $this->dbOptions['db_data_col'];
$dbIdCol   = $this->dbOptions['db_id_col'];

try {
    $sql = "SELECT $dbDataCol FROM $dbTable WHERE $dbIdCol = :id";
    $stmt = $this->pdo->prepare($sql);
    $stmt->bindParam(':id', $id, \PDO::PARAM_STR);

    $stmt->execute();

My piece of code that I use to log in:

public function postLogin()
{
    $rules = [
        'login'     =>  'required',
        'password'  =>  'required'
    ];
    
    $validator = Validator::make(Input::all(), $rules);
    
    if($validator->fails())
    {
        return Redirect::route('login')->withErrors($validator)->withInput();
    }
    else
    {
        $remember = (bool) Input::get('rememberMe', false);
        
        try
        {
            $user = Sentry::authenticate([
                'login'     =>  Input::get('login'),
                'password'  =>  Input::get('password')
            ], $remember);
            
            Session::flash('successes', array_merge((array) Session::get('successes'), ['Witaj, ' . $user->displayname]));
            return Redirect::intended(URL::route('home'));
        }
        catch(Cartalyst\Sentry\Users\WrongPasswordException $e)
        {
            $validator->errors()->add('login', 'Login lub hasło nieprawidłowe.');
            $validator->errors()->add('password', 'Login lub hasło nieprawidłowe.');
            
            return Redirect::route('login')->withErrors($validator)->withInput();
        }
        catch(Cartalyst\Sentry\Users\UserNotFoundException $e)
        {
            $validator->errors()->add('login', 'Login lub hasło nieprawidłowe.');
            $validator->errors()->add('password', 'Login lub hasło nieprawidłowe.');
            
            return Redirect::route('login')->withErrors($validator)->withInput();
        }
        catch(Cartalyst\Sentry\Users\UserNotActivatedException $e)
        {
            Session::flash('dangers', ['Konto nieaktywne. Kliknij na link, który dostałeś mailem. Jeśli go nie dostałeś, skontaktuj się z administratorem.']);

            return Redirect::route('login')->withErrors($validator)->withInput();
        }
        catch(Cartalyst\Sentry\Throttling\UserBannedException $e)
        {
            Session::flash(['dangers', 'Konto zablokowane. Skontaktuj się z administratorem.']);
            
            return Redirect::route('login')->withErrors($validator)->withInput();
        }
    }
}

I'm using database driver for cookies, and error only occurs when Remember Me checked ($remember = true)

È stato utile?

Soluzione 2

Fixed by downgrading form 4.1 to 4. I think it's some kind of bug.

Altri suggerimenti

Fix your authenticate call:

$user = Sentry::authenticate(array(
    'login'     =>  Input::get('login'),
    'password'  =>  Input::get('password')
), $remember);
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top