Re: Question about posts index and auth issue

2012-01-02 Thread heohni
But now I not a step further?
Does anyone has a hint for me?

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Question about posts index and auth issue

2012-01-02 Thread Jeremy Burns | Class Outfit
Surely setting the allow variable is enough. If the user is not logged, they 
are not allowed. Simple. No need to check further, let the auth component do it.

Jeremy Burns
Class Outfit

http://www.classoutfit.com

On 2 Jan 2012, at 14:39:11, luca capra wrote:

> A simple way could be checking if the user is logged in, like
> 
> public function beforeFilter() {
>parent::beforeFilter();
>if($this->Auth->user()) {
> $this->Auth->allow(array('index', 'frontindex'));
>}
> }
> 
> 
> Il 02/01/2012 10:18, heohni ha scritto:
>> Hi,
>> 
>> I have a page, where I want to display my blog posts by calling a
>> requestAction to a function called frontindex() function.
>> public function frontindex() {
>> $all = $this->Post->find('all', array('order' =>  'created
>> DESC'));
>> $this->set('posts', $all);
>> return $all;
>> }
>> I am only displaying the headline and the body, nothing else.
>> 
>> To add new posts and to edit I want the admin to login.
>> After login, the admin should see the index(), with add(), edit() and
>> delete() function.
>> 
>> I wonder now, how to do this best.
>> 
>> In my posts controller I have this:
>> public function beforeFilter() {
>> parent::beforeFilter();
>> $this->Auth->allow(array('frontindex'));
>> }
>> 
>> BUT!
>> 
>> After submitting the login form, I can never reach the index() I just
>> keep seeing the login form.
>> In my AppController I have:
>> public $components = array(
>> 'Session',
>> 'Auth' =>  array(
>> 'loginRedirect' =>  array('controller' =>  'posts', 'action'
>> =>  'index'),
>> 'logoutRedirect' =>  array('controller' =>  'pages',
>> 'action' =>  'display', 'home'),
>> 'authorize' =>  array('Controller'),
>> 'authError' =>  'Bitte loggen Sie sich ein!'
>> )
>> );
>> 
>> 
>> It  only works, when I do this:
>> public function beforeFilter() {
>> parent::beforeFilter();
>> $this->Auth->allow(array('index', 'frontindex'));
>> }
>> Adding the index.
>> BUT then my index is open to the public.
>> 
>> I am totally lost in this, how the hell can I make it right?
>> Please give me some advice!
>> 
> 
> -- 
> Our newest site for the community: CakePHP Video Tutorials 
> http://tv.cakephp.org Check out the new CakePHP Questions site 
> http://ask.cakephp.org and help others with their CakePHP related questions.
> 
> 
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
> http://groups.google.com/group/cake-php

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Question about posts index and auth issue

2012-01-02 Thread luca capra

A simple way could be checking if the user is logged in, like

public function beforeFilter() {
parent::beforeFilter();
if($this->Auth->user()) {
 $this->Auth->allow(array('index', 'frontindex'));
}
}


Il 02/01/2012 10:18, heohni ha scritto:

Hi,

I have a page, where I want to display my blog posts by calling a
requestAction to a function called frontindex() function.
public function frontindex() {
 $all = $this->Post->find('all', array('order' =>  'created
DESC'));
 $this->set('posts', $all);
 return $all;
 }
I am only displaying the headline and the body, nothing else.

To add new posts and to edit I want the admin to login.
After login, the admin should see the index(), with add(), edit() and
delete() function.

I wonder now, how to do this best.

In my posts controller I have this:
public function beforeFilter() {
 parent::beforeFilter();
 $this->Auth->allow(array('frontindex'));
 }

BUT!

After submitting the login form, I can never reach the index() I just
keep seeing the login form.
In my AppController I have:
public $components = array(
 'Session',
 'Auth' =>  array(
 'loginRedirect' =>  array('controller' =>  'posts', 'action'
=>  'index'),
 'logoutRedirect' =>  array('controller' =>  'pages',
'action' =>  'display', 'home'),
 'authorize' =>  array('Controller'),
 'authError' =>  'Bitte loggen Sie sich ein!'
 )
 );


It  only works, when I do this:
public function beforeFilter() {
 parent::beforeFilter();
 $this->Auth->allow(array('index', 'frontindex'));
 }
Adding the index.
BUT then my index is open to the public.

I am totally lost in this, how the hell can I make it right?
Please give me some advice!



--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.



To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Question about posts index and auth issue

2012-01-02 Thread heohni
Hi,

I have a page, where I want to display my blog posts by calling a
requestAction to a function called frontindex() function.
public function frontindex() {
$all = $this->Post->find('all', array('order' => 'created
DESC'));
$this->set('posts', $all);
return $all;
}
I am only displaying the headline and the body, nothing else.

To add new posts and to edit I want the admin to login.
After login, the admin should see the index(), with add(), edit() and
delete() function.

I wonder now, how to do this best.

In my posts controller I have this:
public function beforeFilter() {
parent::beforeFilter();
$this->Auth->allow(array('frontindex'));
}

BUT!

After submitting the login form, I can never reach the index() I just
keep seeing the login form.
In my AppController I have:
public $components = array(
'Session',
'Auth' => array(
'loginRedirect' => array('controller' => 'posts', 'action'
=> 'index'),
'logoutRedirect' => array('controller' => 'pages',
'action' => 'display', 'home'),
'authorize' => array('Controller'),
'authError' => 'Bitte loggen Sie sich ein!'
)
);


It  only works, when I do this:
public function beforeFilter() {
parent::beforeFilter();
$this->Auth->allow(array('index', 'frontindex'));
}
Adding the index.
BUT then my index is open to the public.

I am totally lost in this, how the hell can I make it right?
Please give me some advice!

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php