dongnigeng1295 2013-12-29 22:50
浏览 59
已采纳

使用Cartalyst Sentry登录时,Laravel 4中的数组到字符串转换

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)

  • 写回答

2条回答 默认 最新

  • duan1930 2014-01-06 20:02
    关注

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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 用matlab 设计一个不动点迭代法求解非线性方程组的代码
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试