定制 vojtech-dobes/nette-multi-authenticator 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

vojtech-dobes/nette-multi-authenticator

最新稳定版本:v2.0.0

Composer 安装命令:

composer require vojtech-dobes/nette-multi-authenticator

包简介

Allows definition of multiple authentication ways with unified API (for Nette Framework).

README 文档

README

Allows definition of multiple authentication ways with unified API (for Nette Framework)

License

New BSD

Dependencies

Nette 2.0 or newer

Installation

None, really :).

Usage

Write your authenticators, but don't make them implement Nette\Security\IAuthenticator. On the other hand, request Nette\Security\User service as dependency.

class CredentialsAuthenticator
{

    /** @var Nette\Security\User */
    private $user;
    
    public function __construct(Nette\Security\User $user)
    {
        $this->user = $user;
    }

}

Now write your login method. Be creative!

public function login($username, $password)
{
    // ... your logic
    
    $this->user->login(new Identity( ... ));
}

Register your authenticator as service:

services:
    - CredentialsAuthenticator

And you're done.

For authentication, you should use the specific authenticator:

class SignPresenter extends Nette\Application\UI\Presenter
{

    /** @var CredentialsAuthenticator @inject */
    public $credentialsAuthenticator;

    // ...
    
    public function processLoginForm($form)
    {
        $values = $form->getValues();
        $this->credentialsAuthenticator->login($values->username, $values->password);
    }

}

The point is: use normal dependencies and wrap Nette\Security\User in them, not the other way around.

统计信息

  • 总下载量: 4.68k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 38
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 37
  • Watchers: 4
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: New
  • 更新时间: 2012-11-08