userConfigManager = $userConfigManager; $this->authorization = $authorization; } /** * @param Observer $observer * @return void * @throws \Magento\Framework\Exception\NoSuchEntityException */ public function execute(Observer $observer) { if ($this->authorization->isAllowed('MSP_TwoFactorAuth::tfa')) { $user = $observer->getEvent()->getObject(); $data = $user->getData(); if (isset($data['msp_tfa_providers'])) { if (!is_array($data['msp_tfa_providers'])) { $data['msp_tfa_providers'] = []; } $this->userConfigManager->setProvidersCodes($user->getId(), $data['msp_tfa_providers']); } } } }