mcn/user

此包已被废弃,不再维护。未建议替代包。
关于此包的最新版本(1.0.1)没有提供许可证信息。

提供基本用户功能

安装: 205

依赖: 1

建议者: 0

安全: 0

星标: 4

关注者: 3

分支: 2

开放问题: 2

类型:模块

1.0.1 2013-10-23 08:37 UTC

This package is not auto-updated.

Last update: 2016-03-12 08:35:09 UTC


README

Build Status

配置

将文件 config/mcnuser.global.php.dist 复制到您的应用程序自动加载目录。该文件中应文档化可用的配置选项!

认证

保留结果代码

如果尝试使用其他组件而未遵守,可能会导致意外结果

# The range 1 to -10 is reserved for MCNUser
// Constants are from MCNUser\Authentication\Result
const SUCCESS = 1;
const FAILURE_IDENTITY_NOT_FOUND = -1;
const FAILURE_INVALID_CREDENTIAL = -2;
const FAILURE_UNCATEGORIZED      = -3;
const FAILURE_DISABLED_PLUGIN    = -4;

# The range -10 to -30 is reserved for MCN<SocialNetwork> components such as linkedIn or Facebook
// Constants are from MCNLinkedIn\Authentication\Result
const FAILURE_INVALID_CONFIGURATION = -11;
const FAILURE_ACCESS_DENIED         = -12;

认证事件

// Constants are from MCNUser\Authentication\AuthEvent
const EVENT_LOGOUT       = 'logout';
const EVENT_AUTH_SUCCESS = 'authenticate.success';
const EVENT_AUTH_FAILURE = 'authenticate.failure';

示例用法可以是注入一个监听器来监听认证成功事件并检查用户是否已确认他们的电子邮件账户。为此,我们必须向扩展 MCNUser\Entity\User 的类中添加一个用户 state 属性。

// Example listener could look like this
$authenticationService->getEventManager()->attach(AuthEvent::EVENT_AUTH_SUCCESS, function(Event $e) {

    $user = $e->getResult()->getIdentity();

    if ($user->getState() != User::STATE_CONFIRMED) {

        $e->stopPropagation(true);
        return 'Your email has not yet been confirmed';
    }
});