Hi majna, I will follow your suggestion.
Thanks

On Sunday, March 3, 2013 10:27:24 PM UTC+2, majna wrote:
>
> Hi, here's my suggestions,
>
> - change admin route to
> Router::connect(‘/admin’, array(‘controller’ => ‘users’, ‘action’ => 
> ‘index’, ‘admin’ => true));
>
> - replace your beforeRender() callback with:
>     public function beforeRender() {
>         if (isset($this->request->params['prefix']) && 
> $this->request->params['prefix'] === 'admin') {
>             if (!$this->request->is('ajax') && $this->name !== 'CakeError' 
> && $this->viewPath !== 'Errors') {
>                 $this->layout = 'admin';
>             }
>         }
>     }
>
> - change isAuthorized() callback like in this example:
>
> http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html#using-controllerauthorize
>
> - remove completely beforeFilter() callback (containing 
> $this->Auth->allow(‘*’))
>
> - in each controller list only publicly accessible actions, i.e in Users 
> controller add:
>     public function beforeFilter() {
>         $this->Auth->allow('login', 'logout', 'register');
>         parent::beforeFilter();
>     }
>
> I hope it'll work then...
>
> On Friday, March 1, 2013 8:52:29 PM UTC+1, di wrote:
>>
>> I have this:
>> In routes.php: Router::connect(‘/admin’, array(‘controller’ => ‘users’, 
>> ‘action’ => ‘index’,'add’, ‘admin’ => true,’prefix’ => ‘admin’,'layout’ => 
>> ‘admin’));
>>
>> In core.php: (debug, 0)
>>
>> In appController:
>> class AppController extends Controller {
>> public $components = array(
>> ‘Session’,
>> ‘Auth’=>array(
>> ‘loginRedirect’=>array(‘controller’=>’pagina_inicial’, 
>> ‘action’=>’index’,'admin’=>false),
>> ‘logoutRedirect’=>array(‘controller’=>’users’, ‘action’=>’login’),
>> ‘authError’=>" ”,
>> ‘authorize’=>array(‘Controller’)
>> )
>> ); 
>>
>> public $helpers = array(‘Session’,'form’,'Html’,'PhpExcel’);
>> public $pdfConfig = array(
>> ‘engine’ => ‘CakePdf.Tcpdf’,
>> );
>>
>> public $cacheAction = ’1 hour’;
>>
>> public function isAuthorized($user) {
>> $role=$this->Session->read(‘Auth.User.role’);
>>
>> //die(debug($role));
>> if(isset($this->request->prefix) && $role!=’admin’){
>> return FALSE;
>> }
>> return true;
>> }
>>
>> public function beforeFilter() {
>> $this->Auth->allow(‘*’);
>> //$this->set(‘logged_in’, $this->Auth->loggedIn());
>> //$this->set(‘current_user’, $this->Auth->user());
>>
>> // if its the administrator/manager – change the layout
>> /**if (isset($this->params['prefix']) && $this->params['prefix'] == 
>> ‘admin’) {
>> $this->layout = ‘admin’;
>> } else {
>> $this->layout = ‘user’;
>> }**/
>>
>> }
>> public function beforeRender() {
>> $this->_configureErrorLayout();
>> }
>>
>> public function _configureErrorLayout() {
>> if ($this->name == ‘CakeError’) {
>> if ($this->_isAdminMode()) {
>> $this->layout = ‘admin’;
>> } else {
>> $this->layout = ‘default’;
>> }
>> }
>> }
>>
>> public function _isAdminMode() {
>> $adminRoute = Configure::read(‘Routing.prefixes’);
>> if (isset($this->params['prefix']) && in_array($this->params['prefix'], 
>> $adminRoute)) {
>> return true;
>> }
>> return false;
>> }
>>
>> also have:
>>
>> app/view/layout/default.ctp and app/view/layout/admin.ctp
>> app/view/Homepage/index.ctp and app/view/HomePage/admin_index.ctp
>>
>> But not working, what am I doing wrong, any help please.
>>
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to