【问题标题】:how to activate user with laravel4 auth component如何使用 laravel4 auth 组件激活用户
【发布时间】:2014-06-20 07:43:55
【问题描述】:

我在我的应用程序中使用 laravel 4 身份验证组件。我想知道有没有办法使用 auth inbuilt function 激活和停用用户。我在 codeigniter 中有一个应用程序,用户激活为:

 if ($this->ion_auth->is_admin()) {
        $activation=$this->ion_auth->activate($userId);
    }

请告诉我 laravel auth 是否提供类似的内置激活功能。还有什么是最好的方法来做这个 usng auth 。

我的用户表中有一个“活动”字段。

【问题讨论】:

    标签: laravel-4


    【解决方案1】:

    默认情况下,Laravel Auth 没有任何激活用户的功能。但是,您可以手动完成:

    例如:

    $user = User::find($userId);
    
    $user->activate = 1;
    
    $user->save();
    

    如果您只有电子邮件:

    $user = User::where('email', $email)->first();
    $user->activate = 1;
    
    $user->save();
    

    使用条件验证用户:如果激活,则验证用户。

    if (Auth::attempt(array('email' => $email, 'password' => $password, 'active' => 1)))
    {
        // The user is active, not suspended, and exists.
    }
    

    第三方包:

    如果您想要完整的身份验证功能,可以使用 Sentry。

    https://cartalyst.com/manual/sentry/introduction

    使用 Sentry 激活用户:

    https://cartalyst.com/manual/sentry/users/activate

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-07-24
      • 1970-01-01
      • 2014-08-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-08-13
      • 2017-12-18
      相关资源
      最近更新 更多