daninoz/active-auth

dev-master 2014-02-06 00:54 UTC

This package is not auto-updated.

Last update: 2024-09-24 02:19:43 UTC


README

为Laravel4的Auth组件添加功能,仅允许登录具有活动账户的用户。

设置

composer.json文件的require键中添加

"daninoz/active-auth": "dev-master"

运行Composer更新命令

$ composer update

在你的config/app.php中,将'Daninoz\ActiveAuth\ActiveAuthServiceProvider'添加到$providers数组的末尾

'providers' => array(

    'Illuminate\Foundation\Providers\ArtisanServiceProvider',
    'Illuminate\Auth\AuthServiceProvider',
    ...
    'Daninoz\ActiveAuth\ActiveAuthServiceProvider',

),

配置

将属性值设置为config/auth.php

用户表

在你的用户表中只需要一个活动字段。默认情况下,Active Auth会寻找名为active的字段,但你也可以更改它。

运行

$ php artisan config:publish daninoz/active-auth

并且将在app/config/packages/daninoz/active-auth/config.php创建一个配置文件。只需更改active-field键。

示例

$credentials = [
    'email' => Input::get('email'),
    'password' => Input::get('password')
];

$response = ActiveAuth::activeAttempt($credentials);

switch ($response) {
    case ActiveAuth::INVALID_CREDENTIALS:
    case ActiveAuth::INACTIVE_USER:
        return Redirect::back()->with('error', Lang::get($response));

    case ActiveAuth::SUCCESS:
        return Redirect::intended('/');
}

许可证

Active Auth是免费软件,根据MIT许可证条款分发

Bitdeli Badge