[Flow] how to make active connection to initialize roles for user registration

Rocky rockysynergy at gmail.com
Tue Apr 15 12:56:57 CEST 2014


Hi,

I am making registration form for my TYPO3 Flow application. 

In Policy.yaml I have:
roles:
   subscriber: []

In the RegisterController's I have below code:
public function createAction($identifier, $pass, $pass2) {
       $roles = array('Package.Key:subscriber');
       
       ......
       $account = $this->accountFactory->createAccountWithPassword($name, $pass, $roles);
       $this->accountRepository->add($account);
       $this->flashMessageContainer->addMessage(new \TYPO3\Flow\Error\Error('Account created. Please login.'));
       $this->redirect('index');
}

But I got Exception saying #1353085860: The role with identifier "Package.Key:subscriber" is unknown

It seems when creating the account, PolicyService will skip initializeRolesFromPolicy if there is no active database connection.

How can I set up the active database for roleRepository to make the role I defined in policy.yaml get synchronized into the database when registering the user?


More information about the Flow mailing list