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 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分