cakephproutescakedc

how to give loginredirect in cakedc, Cakephp 3.0


How to give loginredirect in cakephp while using cakedc Users plugin and also tell where these changes are to be done src/controller/AppController or vendor/cakedc/users/src/Controller/AppController

AppContoller of cakedc users plugin
    class AppController extends BaseController
    {
        public function initialize()
        {
            parent::initialize();
            $this->loadComponent('Security');
            $this->loadComponent('Csrf');
            $this->loadComponent('CakeDC/Users.UsersAuth', ['loginAction' => ['controller' => 'Blogs','action' => 'index']]);
         }
    }

Solution

  • You can update defaults in Auth component configuration after the plugin is loaded, like this:

    $this->Auth->config('loginAction', [...your url...]);
    

    Or you can use the config based plugin initialization as suggested here https://github.com/CakeDC/users/blob/master/Docs/Documentation/Configuration.md