cakephp - Where should the template view file for the login function go? -


i trying follow simple authentication , authorization application tutorial not clear template view file login function (below) supposed go.

<div class="users form"> <?php echo $this->session->flash('auth'); ?> <?php echo $this->form->create('user'); ?>     <fieldset>         <legend><?php echo __('please enter username , password'); ?></legend>         <?php echo $this->form->input('username');         echo $this->form->input('password');     ?>     </fieldset> <?php echo $this->form->end(__('login')); ?> </div> 

when put in app/view/users/login.ctp , users/add causes following error:

error: view userscontroller::index() not found. error: confirm have created file: app\view\users\index.ctp 

when app/view/users/login.ctp renamed app/view/users/index.ctp , users/add indicates

the user has been saved

but going blog tutorial root , attempting add causes

error: view userscontroller::login() not found. error: confirm have created file: c:\csvn\www\jack\app\view\users\login.ctp 

so: should template view file login function go? in index, login, or other .ctp?

edit: add app/controller/userscontroller.php code

class userscontroller extends appcontroller {      public function beforefilter() {         parent::beforefilter();         $this->auth->allow('add'); // letting users register     }      public function login() {         if ($this->request->is('post')) {             if ($this->auth->login()) {                 $this->redirect($this->auth->redirect());             } else {                 $this->session->setflash(__('invalid username or password, try again'));             }         }     }      public function logout() {         $this->redirect($this->auth->logout());     }      public function index() {         $this->user->recursive = 0;         $this->set('users', $this->paginate());     }      public function view($id = null) {         $this->user->id = $id;         if (!$this->user->exists()) {             throw new notfoundexception(__('invalid user'));         }         $this->set('user', $this->user->read(null, $id));     }      public function add() {         if ($this->request->is('post')) {             $this->user->create();             if ($this->user->save($this->request->data)) {                 $this->session->setflash(__('the user has been saved'));                 $this->redirect(array('action' => 'index'));             } else {                 $this->session->setflash(__('the user not saved. please, try again.'));             }         }     }      public function edit($id = null) {         $this->user->id = $id;         if (!$this->user->exists()) {             throw new notfoundexception(__('invalid user'));         }         if ($this->request->is('post') || $this->request->is('put')) {             if ($this->user->save($this->request->data)) {                 $this->session->setflash(__('the user has been saved'));                 $this->redirect(array('action' => 'index'));             } else {                 $this->session->setflash(__('the user not saved. please, try again.'));             }         } else {             $this->request->data = $this->user->read(null, $id);             unset($this->request->data['user']['password']);         }     }      public function delete($id = null) {         if (!$this->request->is('post')) {             throw new methodnotallowedexception();         }         $this->user->id = $id;         if (!$this->user->exists()) {             throw new notfoundexception(__('invalid user'));         }         if ($this->user->delete()) {             $this->session->setflash(__('user deleted'));             $this->redirect(array('action' => 'index'));         }         $this->session->setflash(__('user not deleted'));         $this->redirect(array('action' => 'index'));     } } 

edit: add appcontroller

<?php app::uses('controller', 'controller');  class appcontroller extends controller {     public $helpers = array('session');      public $components = array(         'session',         'auth' => array(             'loginredirect' => array('controller' => 'posts', 'action' => 'index'),             'logoutredirect' => array('controller' => 'pages', 'action' => 'display', 'home'),             'authorize' => array('controller') // added line         )     );      public function isauthorized($user) {         // admin can access every action         if (isset($user['role']) && $user['role'] === 'admin') {             return true;         }          // default deny         return false;     }      public function beforefilter() {         $this->auth->allow('index', 'view');     } } 

pulled comment conversation...

"i still think issue missing index.ctp view file. if trying add user explain why error message of missing view when login form located @ view/users/login.ctp because have no file located @ view/users/index.ctp add() action redirecting after adding user successfully."


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -