Exemplo n.º 1
0
 /**
  * ログイン処理
  *
  * @return void
  * @throws InternalErrorException
  **/
 public function login()
 {
     //ページタイトル
     $this->set('pageTitle', __d('auth', 'Login'));
     //メールを送れるかどうか
     $this->set('isMailSend', $this->ForgotPass->isMailSendCommon('auth', 'auth'));
     if ($this->request->is('post')) {
         //Auth->login()を実行すると、$this->UserがUsers.UserからModelAppに置き換わってしまい、
         //エラーになるため、変数に保持しておく。
         $User = $this->User;
         $this->Auth->authenticate['all']['scope'] = array('User.status' => '1');
         if ($this->Auth->login()) {
             $User->updateLoginTime($this->Auth->user('id'));
             Current::write('User', $this->Auth->user());
             if ($this->Auth->user('language') !== UserAttributeChoice::LANGUAGE_KEY_AUTO) {
                 $this->Session->write('Config.language', $this->Auth->user('language'));
             }
             $this->Auth->loginRedirect = $this->SiteSetting->getDefaultStartPage();
             return $this->redirect($this->Auth->redirect());
         }
         $this->NetCommons->setFlashNotification(__d('auth', 'Invalid username or password, try again'), array('class' => 'danger', 'interval' => NetCommonsComponent::ALERT_VALIDATE_ERROR_INTERVAL), 400);
         //$this->redirect($this->Auth->loginAction);
     }
 }
Exemplo n.º 2
0
 /**
  * UserAttribureデータ取得
  *
  * @return array
  */
 public function getUserAttribures()
 {
     if ($this->__userAttributes) {
         return $this->__userAttributes;
     }
     //モデルのロード
     $this->loadModels(['UserAttribute' => 'UserAttributes.UserAttribute']);
     //SiteSettingデータ取得
     Current::write('User.role_key', SiteSettingUtil::read('AutoRegist.role_key'));
     //UserAttributeデータ取得
     $this->__userAttributes = $this->UserAttribute->getUserAttriburesForAutoUserRegist(array('OR' => array('UserAttributeSetting.user_attribute_key' => array(UserAttribute::LOGIN_ID_FIELD, UserAttribute::PASSWORD_FIELD), array('UserAttributeSetting.required' => true, 'UserAttributeSetting.data_type_key' => array(DataType::DATA_TYPE_CHECKBOX, DataType::DATA_TYPE_RADIO, DataType::DATA_TYPE_SELECT)), array('UserAttributeSetting.required' => true, 'UserAttributeSetting.only_administrator_editable' => false), 'UserAttributeSetting.auto_regist_display' => true)));
     return $this->__userAttributes;
 }
Exemplo n.º 3
0
 /**
  * パスワード登録
  *
  * @return void
  **/
 public function update()
 {
     if ($this->request->is('put')) {
         if ($this->ForgotPass->savePassowrd($this->request->data)) {
             $this->NetCommons->setFlashNotification(__d('net_commons', 'Successfully saved.'), array('class' => 'success'));
             $this->Session->delete('ForgotPass');
             $this->Auth->authenticate['all']['scope'] = array('User.status' => '1');
             if ($this->Auth->login()) {
                 $this->User->updateLoginTime($this->Auth->user('id'));
                 Current::write('User', $this->Auth->user());
                 $this->Auth->loginRedirect = $this->SiteSetting->getDefaultStartPage();
                 return $this->redirect($this->Auth->redirect());
             }
             return $this->redirect('/auth/auth/login');
         }
         $this->NetCommons->handleValidationError($this->ForgotPass->validationErrors);
     } else {
         $this->request->data['User']['id'] = $this->Session->read('ForgotPass.user_id');
     }
 }
 /**
  * getQueryOptions()のテスト
  *
  * @param int $userId ユーザID
  * @param int $status ステータス
  * @param array $options オプション
  * @param array $expected 期待値
  * @dataProvider dataProviderByFlatWOStatus
  * @return void
  */
 protected function _testGetQueryOptions($userId, $status, $options, $expected)
 {
     $model = $this->_modelName;
     $methodName = $this->_methodName;
     //データ生成
     if ($userId) {
         Current::write('User.id', $userId);
     }
     //テスト実施
     $result = $this->{$model}->find('all', Hash::merge(array('fields' => array('Topic.id', 'Topic.content_key', 'Topic.category_id', 'TopicReadable.id', 'TopicReadable.user_id', 'TopicUserStatus.id', 'Category.id')), $this->{$model}->{$methodName}($status, $options)));
     //チェック
     $this->assertEquals($result, $expected);
 }