CakePHP admin section routing and redirecting

后端 未结 4 1686
醉梦人生
醉梦人生 2021-02-20 09:49

I\'m struggling with the concept of creating an admin section in CakePHP-project. (version 2.3.5)

I have uncommented the line in Config/core.php:

Configu         


        
4条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-20 10:45

    Try This

    Your config/routes.php

    Router::connect('/', array('controller' => 'users', 'action' => 'dashboard' ));

    Appcontroller

    class AppController extends Controller {
    
    public $components = array(
        'Acl',
        'Session',
        'Auth' => array(
            'authenticate' => array(
                'Form' => array( 
                    'userModel' => 'User',
                     'fields' => array(
                        'username' => 'user_name',
                        'password' => 'password'
                        )
                    )
                ),
            'loginAction' => array('controller' => 'users', 'action' => 'login'),
                        'loginRedirect' => array('controller' => 'users', 'action' => 'mysettings'),
            'logoutRedirect' => array('controller' => 'users', 'action' => 'login'),
            'authError' => 'You don\'t have access here.',
                    /*
                    'loginAction' => array('controller' => 'users', 'action' => 'forgot_password'),
                    'loginRedirect' => array('controller' => 'users', 'action' => 'dashboard'),
                    'logoutRedirect' => array('controller' => 'users', 'action' => 'forgot_password'),
                    'authError' => 'You don\'t have access here.',
                    */
            ),
    
    );
    

    Usercontroller

    class UsersController extends AppController {
    
    /**
     * Components
     *
     * @var array
     */ 
    public function beforeFilter() {
        parent::beforeFilter();
        $this->Auth->allow('login','logout');
    }
    
    }
    

提交回复
热议问题