holabs/security

Add ability to use more authentifications in same time in your Nette Framework project

v1.0.9 2018-06-20 09:56 UTC

This package is auto-updated.

Last update: 2024-10-12 21:45:20 UTC


README

Adding ability for use more authentication methods a.k.a basic form, facebook and google in same time. THIS package contains only basic form.

Installation

Requirements:

composer require holabs/security

Configuration

security: Holabs\Security\Bridges\Nette\SecurityExtension

security:
	authenticators:
		basic: Holabs\Security\Authenticators\Basic
#		auth_name: authenticator\class

In authenticators you can define all your authenticators. Name is used for component.

Using

Your SignPresenter now can looks like this:

<?php 

use Holabs\Security\Container;
use Nette\Application\UI\Presenter;
use Nette\Application\UI\Multiplier;

/**
 * @author       Tomáš Holan <mail@tomasholan.eu>, D-Music s.r.o. [www.d-music.cz]
 * @package      holabs/security
 * @copyright    Copyright © 2016, D-Music s.r.o. [www.d-music.cz]
 */
class SignPresenter extends Presenter {
	
	/** @var Container @inject */
    public $container;
    
    public function renderIn(){
		$this->template->authenticators = $this->container->getAuthenticators();
	}
	
	/**
	 * @return Multiplier
	 */
	protected function createComponentLogin(){
		return new Multiplier(function($name) {

			return $this->container->getAuthenticator($name);

		});
	}
}

No you can render what you want. You can render all in in.latte

<div n:inner-foreach="$authenticators as $name => $authenticator">
	{control $authenticator}
	{*control $authenticators-{$name}*}
</div>

OR only which you want(authenticator name is same as you define in config file)

<div>
	{control $authenticators-basic}
</div>