コード例 #1
0
ファイル: SessionController.php プロジェクト: ntoniazzi/PHPCI
 /**
  * Handles user login (form and processing)
  */
 public function login()
 {
     $isLoginFailure = false;
     if ($this->request->getMethod() == 'POST') {
         $token = $this->getParam('token');
         if (!isset($token, $_SESSION['login_token']) || $token !== $_SESSION['login_token']) {
             $isLoginFailure = true;
         } else {
             unset($_SESSION['login_token']);
             $user = $this->userStore->getByEmail($this->getParam('email'));
             if ($user && password_verify($this->getParam('password', ''), $user->getHash())) {
                 session_regenerate_id(true);
                 $_SESSION['phpci_user_id'] = $user->getId();
                 $response = new b8\Http\Response\RedirectResponse();
                 $response->setHeader('Location', $this->getLoginRedirect());
                 return $response;
             } else {
                 $isLoginFailure = true;
             }
         }
     }
     $form = new b8\Form();
     $form->setMethod('POST');
     $form->setAction(PHPCI_URL . 'session/login');
     $email = new b8\Form\Element\Email('email');
     $email->setLabel(Lang::get('email_address'));
     $email->setRequired(true);
     $email->setContainerClass('form-group');
     $email->setClass('form-control');
     $form->addField($email);
     $pwd = new b8\Form\Element\Password('password');
     $pwd->setLabel(Lang::get('password'));
     $pwd->setRequired(true);
     $pwd->setContainerClass('form-group');
     $pwd->setClass('form-control');
     $form->addField($pwd);
     $pwd = new b8\Form\Element\Submit();
     $pwd->setValue(Lang::get('log_in'));
     $pwd->setClass('btn-success');
     $form->addField($pwd);
     $tokenValue = $this->generateToken();
     $_SESSION['login_token'] = $tokenValue;
     $token = new b8\Form\Element\Hidden('token');
     $token->setValue($tokenValue);
     $form->addField($token);
     $this->view->form = $form->render();
     $this->view->failed = $isLoginFailure;
     return $this->view->render();
 }
コード例 #2
0
ファイル: SessionController.php プロジェクト: kukupigs/PHPCI
 /**
  * Handles user login (form and processing)
  */
 public function login()
 {
     $isLoginFailure = false;
     if ($this->request->getMethod() == 'POST') {
         $user = $this->userStore->getByEmail($this->getParam('email'));
         if ($user && password_verify($this->getParam('password', ''), $user->getHash())) {
             $_SESSION['user_id'] = $user->getId();
             header('Location: ' . $this->getLoginRedirect());
             die;
         } else {
             $isLoginFailure = true;
         }
     }
     $form = new b8\Form();
     $form->setMethod('POST');
     $form->setAction(PHPCI_URL . 'session/login');
     $email = new b8\Form\Element\Email('email');
     $email->setLabel('Email Address');
     $email->setRequired(true);
     $email->setContainerClass('form-group');
     $email->setClass('form-control');
     $form->addField($email);
     $pwd = new b8\Form\Element\Password('password');
     $pwd->setLabel('Password');
     $pwd->setRequired(true);
     $pwd->setContainerClass('form-group');
     $pwd->setClass('form-control');
     $form->addField($pwd);
     $pwd = new b8\Form\Element\Submit();
     $pwd->setValue('Log in »');
     $pwd->setClass('btn-success');
     $form->addField($pwd);
     $this->view->form = $form->render();
     $this->view->failed = $isLoginFailure;
     return $this->view->render();
 }
コード例 #3
0
 /**
  * Get the email settings form.
  * @param array $values
  * @return Form
  */
 protected function getEmailForm($values = array())
 {
     $form = new Form();
     $form->setMethod('POST');
     $form->setAction(PHPCI_URL . 'settings/email');
     $form->addField(new Form\Element\Csrf('csrf'));
     $field = new Form\Element\Text('smtp_address');
     $field->setRequired(false);
     $field->setLabel(Lang::get('smtp_server'));
     $field->setClass('form-control');
     $field->setContainerClass('form-group');
     $field->setValue('localhost');
     $form->addField($field);
     $field = new Form\Element\Text('smtp_port');
     $field->setRequired(false);
     $field->setPattern('[0-9]+');
     $field->setLabel(Lang::get('smtp_port'));
     $field->setClass('form-control');
     $field->setContainerClass('form-group');
     $field->setValue(25);
     $form->addField($field);
     $field = new Form\Element\Text('smtp_username');
     $field->setRequired(false);
     $field->setLabel(Lang::get('smtp_username'));
     $field->setClass('form-control');
     $field->setContainerClass('form-group');
     $form->addField($field);
     $field = new Form\Element\Password('smtp_password');
     $field->setRequired(false);
     $field->setLabel(Lang::get('smtp_password'));
     $field->setClass('form-control');
     $field->setContainerClass('form-group');
     $form->addField($field);
     $field = new Form\Element\Email('from_address');
     $field->setRequired(false);
     $field->setLabel(Lang::get('from_email_address'));
     $field->setClass('form-control');
     $field->setContainerClass('form-group');
     $form->addField($field);
     $field = new Form\Element\Email('default_mailto_address');
     $field->setRequired(false);
     $field->setLabel(Lang::get('default_notification_address'));
     $field->setClass('form-control');
     $field->setContainerClass('form-group');
     $form->addField($field);
     $field = new Form\Element\Select('smtp_encryption');
     $field->setOptions(array('' => Lang::get('none'), 'tls' => Lang::get('tls'), 'ssl' => Lang::get('ssl')));
     $field->setRequired(false);
     $field->setLabel(Lang::get('use_smtp_encryption'));
     $field->setContainerClass('form-group');
     $field->setValue(1);
     $form->addField($field);
     $field = new Form\Element\Submit();
     $field->setValue(Lang::get('save'));
     $field->setClass('btn btn-success pull-right');
     $form->addField($field);
     $form->setValues($values);
     return $form;
 }
コード例 #4
0
ファイル: UserController.php プロジェクト: mrudtf/PHPCI
 /**
  * Create user add / edit form.
  */
 protected function userForm($values, $type = 'add')
 {
     $form = new Form();
     $form->setMethod('POST');
     $form->setAction(PHPCI_URL . 'user/' . $type);
     $form->addField(new Form\Element\Csrf('csrf'));
     $field = new Form\Element\Email('email');
     $field->setRequired(true);
     $field->setLabel(Lang::get('email_address'));
     $field->setClass('form-control');
     $field->setContainerClass('form-group');
     $form->addField($field);
     $field = new Form\Element\Text('name');
     $field->setRequired(true);
     $field->setLabel(Lang::get('name'));
     $field->setClass('form-control');
     $field->setContainerClass('form-group');
     $form->addField($field);
     $field = new Form\Element\Password('password');
     if ($type == 'add') {
         $field->setRequired(true);
         $field->setLabel(Lang::get('password'));
     } else {
         $field->setRequired(false);
         $field->setLabel(Lang::get('password_change'));
     }
     $field->setClass('form-control');
     $field->setContainerClass('form-group');
     $form->addField($field);
     $field = new Form\Element\Checkbox('is_admin');
     $field->setRequired(false);
     $field->setCheckedValue(1);
     $field->setLabel(Lang::get('is_user_admin'));
     $field->setContainerClass('form-group');
     $form->addField($field);
     $field = new Form\Element\Submit();
     $field->setValue(Lang::get('save_user'));
     $field->setClass('btn-success');
     $form->addField($field);
     $form->setValues($values);
     return $form;
 }
コード例 #5
0
ファイル: UserController.php プロジェクト: kukupigs/PHPCI
 /**
  * Create user add / edit form.
  */
 protected function userForm($values, $type = 'add')
 {
     $form = new Form();
     $form->setMethod('POST');
     $form->setAction(PHPCI_URL . 'user/' . $type);
     $form->addField(new Form\Element\Csrf('csrf'));
     $field = new Form\Element\Email('email');
     $field->setRequired(true);
     $field->setLabel('Email Address');
     $field->setClass('form-control');
     $field->setContainerClass('form-group');
     $form->addField($field);
     $field = new Form\Element\Text('name');
     $field->setRequired(true);
     $field->setLabel('Name');
     $field->setClass('form-control');
     $field->setContainerClass('form-group');
     $form->addField($field);
     $field = new Form\Element\Password('password');
     if ($type == 'add') {
         $field->setRequired(true);
         $field->setLabel('Password');
     } else {
         $field->setRequired(false);
         $field->setLabel('Password (leave blank to keep current password)');
     }
     $field->setClass('form-control');
     $field->setContainerClass('form-group');
     $form->addField($field);
     $field = new Form\Element\Checkbox('is_admin');
     $field->setRequired(false);
     $field->setCheckedValue(1);
     $field->setLabel('Is this user an administrator?');
     $field->setContainerClass('form-group');
     $form->addField($field);
     $field = new Form\Element\Submit();
     $field->setValue('Save User');
     $field->setClass('btn-success');
     $form->addField($field);
     $form->setValues($values);
     return $form;
 }
コード例 #6
0
ファイル: SettingsController.php プロジェクト: bztrn/PHPCI
 protected function getEmailForm($values = array())
 {
     $form = new Form();
     $form->setMethod('POST');
     $form->setAction(PHPCI_URL . 'settings/email');
     $form->addField(new Form\Element\Csrf('csrf'));
     $field = new Form\Element\Text('smtp_address');
     $field->setRequired(false);
     $field->setLabel('SMTP Server');
     $field->setClass('form-control');
     $field->setContainerClass('form-group');
     $field->setValue('localhost');
     $form->addField($field);
     $field = new Form\Element\Text('smtp_port');
     $field->setRequired(false);
     $field->setPattern('[0-9]+');
     $field->setLabel('SMTP Port');
     $field->setClass('form-control');
     $field->setContainerClass('form-group');
     $field->setValue(25);
     $form->addField($field);
     $field = new Form\Element\Text('smtp_username');
     $field->setRequired(false);
     $field->setLabel('SMTP Username');
     $field->setClass('form-control');
     $field->setContainerClass('form-group');
     $form->addField($field);
     $field = new Form\Element\Text('smtp_password');
     $field->setRequired(false);
     $field->setLabel('SMTP Password');
     $field->setClass('form-control');
     $field->setContainerClass('form-group');
     $form->addField($field);
     $field = new Form\Element\Email('from_address');
     $field->setRequired(false);
     $field->setLabel('From Email Address');
     $field->setClass('form-control');
     $field->setContainerClass('form-group');
     $form->addField($field);
     $field = new Form\Element\Email('default_mailto_address');
     $field->setRequired(false);
     $field->setLabel('Default Notification Address');
     $field->setClass('form-control');
     $field->setContainerClass('form-group');
     $form->addField($field);
     $field = new Form\Element\Checkbox('smtp_encryption');
     $field->setCheckedValue(1);
     $field->setRequired(false);
     $field->setLabel('Use SMTP encryption?');
     $field->setContainerClass('form-group');
     $field->setValue(1);
     $form->addField($field);
     $field = new Form\Element\Submit();
     $field->setValue('Save »');
     $field->setClass('btn btn-success pull-right');
     $form->addField($field);
     $form->setValues($values);
     return $form;
 }