public function execute($request)
 {
     $this->form = new sfForm();
     $this->form->setValidator('confirmPassword', new sfValidatorString(array('required' => true)));
     $this->form->setWidget('confirmPassword', new sfWidgetFormInputPassword());
     $this->form->setValidator('email', new sfValidatorEmail(array('required' => true)));
     $this->form->setWidget('email', new sfWidgetFormInput());
     $this->form->setValidator('password', new sfValidatorString(array('required' => true)));
     $this->form->setWidget('password', new sfWidgetFormInputPassword());
     $this->form->setValidator('siteDescription', new sfValidatorString());
     $this->form->setWidget('siteDescription', new sfWidgetFormInput());
     $this->form->setValidator('siteTitle', new sfValidatorString(array('required' => true)));
     $this->form->setWidget('siteTitle', new sfWidgetFormInput());
     $this->form->setValidator('username', new sfValidatorString(array('required' => true)));
     $this->form->setWidget('username', new sfWidgetFormInput());
     $this->form->getValidatorSchema()->setPostValidator(new sfValidatorSchemaCompare('password', '==', 'confirmPassword'));
     if ($request->isMethod('post')) {
         $this->form->bind($request->getPostParameters());
         if ($this->form->isValid()) {
             $setting = new QubitSetting();
             $setting->name = 'siteTitle';
             $setting->value = $this->form->getValue('siteTitle');
             $setting->save();
             $setting = new QubitSetting();
             $setting->name = 'siteDescription';
             $setting->value = $this->form->getValue('siteDescription');
             $setting->save();
             $user = new QubitUser();
             $user->username = $this->form->getValue('username');
             $user->email = $this->form->getValue('email');
             $user->setPassword($this->form->getValue('password'));
             $user->save();
             $aclUserGroup = new QubitAclUserGroup();
             $aclUserGroup->userId = $user->id;
             $aclUserGroup->groupId = QubitAclGroup::ADMINISTRATOR_ID;
             $aclUserGroup->save();
             $this->redirect(array('module' => 'sfInstallPlugin', 'action' => 'clearCache'));
         }
     }
 }
Example #2
0
<?php

require_once dirname(__FILE__) . '/../../bootstrap/functional.php';
$browser = new sfTestFunctional(new sfBrowser());
$user = new QubitUser();
$user->username = '******';
$user->email = '*****@*****.**';
$user->setPassword('test1234');
$user->save();
$browser->info('Log in')->post(';user/login', array('email' => '*****@*****.**', 'password' => 'test1234'))->with('request')->begin()->isParameter('module', 'user')->isParameter('action', 'login')->end();
$browser->test()->ok($browser->getUser()->isAuthenticated(), 'User is authenticated');
$browser->test()->isa_ok($browser->getUser()->user, 'QubitUser', 'myUser->user is QubitUser');
$browser->info('Log out')->get('/')->with('request')->begin()->isParameter('module', 'staticpage')->isParameter('action', 'static')->end()->click('Log out')->with('request')->begin()->isParameter('module', 'user')->isParameter('action', 'logout')->end();
$browser->test()->ok(!$browser->getUser()->isAuthenticated(), 'User isn\'t authenticated');
$browser = new sfTestFunctional(new sfBrowser());
$browser->info('Incorrect log in')->post(';user/login', array('email' => '*****@*****.**', 'password' => 'wrongpass'))->with('request')->begin()->isParameter('module', 'user')->isParameter('action', 'login')->end();
$browser->test()->ok(!$browser->getUser()->isAuthenticated(), 'User isn\'t authenticated');
$browser->test()->is($browser->getUser()->user, null, 'myUser->user is null');
$browser = new sfTestFunctional(new sfBrowser());
$browser->info('"localhost" "next" parameter, issue 1342')->post(';user/login', array('email' => '*****@*****.**', 'password' => 'test1234', 'next' => 'http://localhost/example'))->with('request')->begin()->isParameter('module', 'user')->isParameter('action', 'login')->end();
$browser->test()->ok($browser->getUser()->isAuthenticated(), 'User is authenticated');
$browser->test()->isa_ok($browser->getUser()->user, 'QubitUser', 'myUser->user is QubitUser');
$browser = new sfTestFunctional(new sfBrowser());
$browser->info('Empty "next" parameter')->post(';user/login', array('email' => '*****@*****.**', 'password' => 'test1234', 'next' => ''))->with('request')->begin()->isParameter('module', 'user')->isParameter('action', 'login')->end();
$browser->test()->ok($browser->getUser()->isAuthenticated(), 'User is authenticated');
$browser->test()->isa_ok($browser->getUser()->user, 'QubitUser', 'myUser->user is QubitUser');
$user->delete();
 /**
  * Creates a new AtoM user from Shibboleth data
  * and assignes a random password
  *
  * @param sfWebRequest $request the current web request
  *
  * @return QubitUser $user The newly created user.
  * 
  */
 protected function createUserFromShibInfo($request)
 {
     $params = $request->getPathInfoArray();
     $username = $this->generateUserNameFromShibInfo($request);
     $password = $this->generateRandomPassword();
     $user = new QubitUser();
     $user->username = $username;
     $user->email = $params['mail'];
     $user->save();
     $user->setPassword($password);
     return $user;
 }