Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Different folder according to Token #10

Open
grimmlink opened this issue Sep 9, 2019 · 2 comments
Open

Different folder according to Token #10

grimmlink opened this issue Sep 9, 2019 · 2 comments

Comments

@grimmlink
Copy link

Hi,

I'm using Symfony 4.3 and trying to have a different folder according to logged in User. I managed to create an event subscriber plugin, but inside of it there is no way to access the logged User.

I need to access a property of it, any idea how to ?

Also I found what I believe is a bug in the connector code:

In ckfinder/ckfinder-symfony-bundle/_connector/Config.php line 481
array_replace_recursive($values, $this->options[$nodeName])
should be
array_replace_recursive($this->options[$nodeName], $values)

@Mick3DIY
Copy link

Mick3DIY commented Jul 20, 2020

Salut @grimmlink,

I confirm the bug for array__replace__recursive($this->options[$nodeName], $values) in ckfinder-symfony-bundle/_connector/Config.php.... Works better now !

I have the same case as you : one folder per logged user.

For example, in my config/packages/ckfinder.yml :

ckfinder:  
    connector:
	backends:  
	    default:
	    # Other options...
	resourceTypes:
	    CKFUserFolder:
		    name: MyFolder
		    backend: default
		    # I'm not using 'Files' or 'Images' default folders

In my src/Security/CKFinderAuthenticator.php :

public function authenticate()
{
    $auth = $this->container->get('security.authorization_checker');
    if ($auth->isGranted('IS_AUTHENTICATED_FULLY')) {
	    $user = $this->container->get('security.token_storage')->getToken()->getUser();
	    $ckfinder = $this->container->get('ckfinder.connector');  

	    //The user folder : Username in my project
	    $ckfinder['config']->extend('resourceTypes', [
		    'MyFolder' => ['directory' => $user->getUserName()]
	    ]);

	    //Check your config object and/or node :
	    //dd($ckfinder['config']->getResourceTypeNode('MyFolder'));
	    return true;
    }
    return false;
}

May be someone can confirm and add this issue to the next pull request with a unit test ? @zaak ? :)

Cheers !

@matthieu2607
Copy link

Hi,
I also confirm the bug, thank you @Mick3DIY for this complete example

@zaak, can you do the test on your end?

thanks in advance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants