Я пытаюсь синхронизировать приложение yii с take php. Основной мотив – войти в обе системы, если пользователь заполнит форму в одном приложении. Приложение yii находится на корне, а приложение для торта php находится в папке. следовательно, URL-адрес
для yii его http://192.168.1.31/Eb/
и для торта php его http://192.168.1.31/Eb/projectmanager/
они локальны.
Теперь я создал функцию в контроллере yii с curl и вызывается это во время входа в систему.
private function logintoprojectmanager($post) { $fields = array( 'User'=>array( 'email' => 'manoj@rudrainnovatives.com', 'password' => 'manoj@41@' ) ); $urltopost="http://192.168.1.31/Eb/projectmanager/login"; $fields_string = http_build_query($fields); $ch = curl_init ($urltopost); curl_setopt ($ch, CURLOPT_POST, true); curl_setopt ($ch, CURLOPT_POSTFIELDS, $fields_string); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, false); $returndata = curl_exec ($ch); curl_close ($ch); print_r($returndata); //display the reuslt*/ die; }
и функция входа в приложение cake php
public function login() { $this->__login(); $this->render('login'); } private function __login() { $this->layout = 'default'; if (AuthComponent::user()) $this->redirect(array('controller' => 'projects', 'action' => 'index')); if ($this->request->is('post')) { $this->User->set($this->request->data); if ($this->Auth->login()) { echo "logged in "; if ($this->request->data['User']['remember_me'] == 1) { unset($this->request->data['User']['remember_me']); $this->request->data['User']['password'] = $this->Auth->password($this->request->data['User']['password']); $this->Cookie->write('cepp_pauth', $this->request->data['User'], true, '2 weeks'); } if (!AppAuth::is(UserRoles::Admin) && AppConfig::read('System.maintenance') === true) { $this->Session->setFlash(__('The system is in maintenance mode.'), Flash::Error); $this->redirect($this->Auth->logout()); } $this->Session->setFlash(__('You successfully logged in.'), Flash::Success); if (!empty($this->request->params['admin'])) $this->redirect(array('controller' => 'projects', 'action' => 'index')); else $this->redirect($this->Auth->redirectUrl()); } else { echo "incorrect credentials"; unset($this->request->data['User']['password']); $this->Session->setFlash(__('The username/password you provided were incorrect.')); } } $this->set('title_for_layout', __('Login')); }
неpublic function login() { $this->__login(); $this->render('login'); } private function __login() { $this->layout = 'default'; if (AuthComponent::user()) $this->redirect(array('controller' => 'projects', 'action' => 'index')); if ($this->request->is('post')) { $this->User->set($this->request->data); if ($this->Auth->login()) { echo "logged in "; if ($this->request->data['User']['remember_me'] == 1) { unset($this->request->data['User']['remember_me']); $this->request->data['User']['password'] = $this->Auth->password($this->request->data['User']['password']); $this->Cookie->write('cepp_pauth', $this->request->data['User'], true, '2 weeks'); } if (!AppAuth::is(UserRoles::Admin) && AppConfig::read('System.maintenance') === true) { $this->Session->setFlash(__('The system is in maintenance mode.'), Flash::Error); $this->redirect($this->Auth->logout()); } $this->Session->setFlash(__('You successfully logged in.'), Flash::Success); if (!empty($this->request->params['admin'])) $this->redirect(array('controller' => 'projects', 'action' => 'index')); else $this->redirect($this->Auth->redirectUrl()); } else { echo "incorrect credentials"; unset($this->request->data['User']['password']); $this->Session->setFlash(__('The username/password you provided were incorrect.')); } } $this->set('title_for_layout', __('Login')); }
изpublic function login() { $this->__login(); $this->render('login'); } private function __login() { $this->layout = 'default'; if (AuthComponent::user()) $this->redirect(array('controller' => 'projects', 'action' => 'index')); if ($this->request->is('post')) { $this->User->set($this->request->data); if ($this->Auth->login()) { echo "logged in "; if ($this->request->data['User']['remember_me'] == 1) { unset($this->request->data['User']['remember_me']); $this->request->data['User']['password'] = $this->Auth->password($this->request->data['User']['password']); $this->Cookie->write('cepp_pauth', $this->request->data['User'], true, '2 weeks'); } if (!AppAuth::is(UserRoles::Admin) && AppConfig::read('System.maintenance') === true) { $this->Session->setFlash(__('The system is in maintenance mode.'), Flash::Error); $this->redirect($this->Auth->logout()); } $this->Session->setFlash(__('You successfully logged in.'), Flash::Success); if (!empty($this->request->params['admin'])) $this->redirect(array('controller' => 'projects', 'action' => 'index')); else $this->redirect($this->Auth->redirectUrl()); } else { echo "incorrect credentials"; unset($this->request->data['User']['password']); $this->Session->setFlash(__('The username/password you provided were incorrect.')); } } $this->set('title_for_layout', __('Login')); }
неpublic function login() { $this->__login(); $this->render('login'); } private function __login() { $this->layout = 'default'; if (AuthComponent::user()) $this->redirect(array('controller' => 'projects', 'action' => 'index')); if ($this->request->is('post')) { $this->User->set($this->request->data); if ($this->Auth->login()) { echo "logged in "; if ($this->request->data['User']['remember_me'] == 1) { unset($this->request->data['User']['remember_me']); $this->request->data['User']['password'] = $this->Auth->password($this->request->data['User']['password']); $this->Cookie->write('cepp_pauth', $this->request->data['User'], true, '2 weeks'); } if (!AppAuth::is(UserRoles::Admin) && AppConfig::read('System.maintenance') === true) { $this->Session->setFlash(__('The system is in maintenance mode.'), Flash::Error); $this->redirect($this->Auth->logout()); } $this->Session->setFlash(__('You successfully logged in.'), Flash::Success); if (!empty($this->request->params['admin'])) $this->redirect(array('controller' => 'projects', 'action' => 'index')); else $this->redirect($this->Auth->redirectUrl()); } else { echo "incorrect credentials"; unset($this->request->data['User']['password']); $this->Session->setFlash(__('The username/password you provided were incorrect.')); } } $this->set('title_for_layout', __('Login')); }
Я получаю завиток, который «вошел в систему». Но когда я открываю приложение php для торта, он перенаправляет меня на регистрационную форму. Где я ошибаюсь ???
любая помощь будет назначена. благодаря