php – 尚未为用户提供hasher

发布时间:2022-04-30 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了php – 尚未为用户提供hasher脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
我似乎无法让哨兵工作.我一直收到此错误:没有为用户提供哈希.有谁知道会发生什么?

我在OS X 10.9上运行MamP.
我使用的是PHP 5.4.4
已安装并启用MCrypt.
尝试在创建新用户时散列密码时会发生此错误.
我们的项目使用laravel Sentry插件.
这是控制器:

<?PHP

use Auth,BaseController,Form,Input,redirect,Sentry,View;

class AuthController extends BaseController {

        public function register()
        {
            return View::make('Auth.register');
        }

        public function handleRegister()
        {
               $validator = Validator::make(Input::all(),User::$rules);

                if ($validator->passes()) {
                    //The registration has passed,create a user

            $user = new User;
                    $user->First_name = Input::get('first_name');
                    $user->last_name = Input::get('last_name');
                    $user->email = Input::get('email');
                    $user->password = Hash::make(Input::get('password'));
                    $user->activated = 1;
                    $user->save();

            //grabbing the Sentry model of the user so we can save IT to the apPRopriate group
            $sentryUser = Sentry::findUserByLogin($user->email);

            if (Input::get('userTyPE') == 'Promoter')
            {
              $group = 'Promoters';
            }
            else
            {
              $group = 'Agents';
            }

            // Find the group using the group id
            $group = Sentry::findGroupByName($group);

            // Assign the group to the user
           $sentryUser->addGroup($group);

                    return Redirect::action('AuthController@LOGin')->with('message','Thanks for registering!');
                } else {
                // validation has Failed,display error messages   
                    return Redirect::action('AuthController@register')->with('message','The following errors occurred')->withErrors($validator)->with@R_502_1400@;

                }
        }

        /**
         * Display the login page
         * @return View
         */
        public function login()
        {
                return View::make('Auth.login');
        }

        /**
         * Login action
         * @return Redirect
         */
        public function handleLogin()
        {
                $credentials = array(
                        'email' => Input::get('email'),'password' => Input::get('password')
                );

                try
                {
                        $user = Sentry::authenticate($credentials,false);

                        if ($user)
                        {
                                return Redirect::action('OfferController@offer');
                        }
                }
                catch(\Exception $e)
                {
                        return Redirect::action('AuthController@login')->withErrors(array('login' => $e->getMessage()));
                }
        }

        /**
         * logout action
         * @return Redirect
         */
        public function logout()
        {
                Sentry::logout();

                return Redirect::action('AuthController@login')->with('message','You have been logged out');
        }

}

?>
问题是,当您将Sentry配置为使用User.PHP作为模型时,它会丢失Sentry hasher.解决方案是在用户注册时设置哈希
$user->setHasher(new Cartalyst\Sentry\hashing\NativeHasher);

脚本宝典总结

以上是脚本宝典为你收集整理的php – 尚未为用户提供hasher全部内容,希望文章能够帮你解决php – 尚未为用户提供hasher所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。