[SOLVED]How to Update the Role At Authentication Provider


(pawan kumar) #1

Hi

Since i am creating the user on fly if the user doesn’t exist.
But I will have to update the role too on fly if the user exist.

Please file below code for the same

if($account === null){

            $account = $this->accountFactory->createAccountWithPassword($accountIdentifier, $password, $groups, 'Neos.Neos:Backend');
            $this->partyService->assignAccountToParty($account, $user);
            $account->setExpirationDate(new \DateTime('+1 week'));
            $this->accountRepository->add($account);
        }else{
           //TODO here i need to write the code

        }

(Soren Malling) #2

$account->addRole(new Role('RoleIdentifier'));


(pawan kumar) #3

Thanks.
It Worked.