예제 #1
0
 /**
  * Action for creating a new user backend
  */
 public function createuserbackendAction()
 {
     $this->assertPermission('config/application/userbackend');
     $form = new UserBackendConfigForm();
     $form->setTitle($this->translate('Create New User Backend'));
     $form->addDescription($this->translate('Create a new backend for authenticating your users. This backend' . ' will be added at the end of your authentication order.'));
     $form->setIniConfig(Config::app('authentication'));
     $form->setResourceConfig(ResourceFactory::getResourceConfigs());
     $form->setRedirectUrl('config/userbackend');
     $form->handleRequest();
     $this->view->form = $form;
     $this->render('userbackend/create');
 }
예제 #2
0
 /**
  * Create a new user backend
  */
 public function createuserbackendAction()
 {
     $this->assertPermission('config/application/userbackend');
     $form = new UserBackendConfigForm();
     $form->setRedirectUrl('config/userbackend');
     $form->setTitle($this->translate('Create New User Backend'));
     $form->addDescription($this->translate('Create a new backend for authenticating your users. This backend' . ' will be added at the end of your authentication order.'));
     $form->setIniConfig(Config::app('authentication'));
     try {
         $form->setResourceConfig(ResourceFactory::getResourceConfigs());
     } catch (ConfigurationError $e) {
         if ($this->hasPermission('config/application/resources')) {
             Notification::error($e->getMessage());
             $this->redirectNow('config/createresource');
         }
         throw $e;
         // No permission for resource configuration, show the error
     }
     $form->setOnSuccess(function (UserBackendConfigForm $form) {
         try {
             $form->add(array_filter($form->getValues()));
         } catch (Exception $e) {
             $form->error($e->getMessage());
             return false;
         }
         if ($form->save()) {
             Notification::success(t('User backend successfully created'));
             return true;
         }
         return false;
     });
     $form->handleRequest();
     $this->view->form = $form;
     $this->render('form');
 }