If you want the login form to load in place of whatever would normally
be returned, you can simply render it (if your login form is an
element) instead of the recipe.
if ($this->Auth->user() == null)
{
$this->viewPath = 'elements/users';
$this->render('login');
}
else
{
// normal code ...
}
If you want the entire page to be refreshed to the login screen, just
send back something in the response that your JS code will check for.
If found, instead of loading the content into the page, change the
location to your login page.
On Wed, Jul 15, 2009 at 5:01 AM, Luke<[email protected]> wrote:
>
> Hi,
>
> I am still working on my first Cake Project and I am now stuck in some
> AJAX Request where I would need some feedback.
>
> I am trying to achieve the following.
>
> I have recipes everybody can see. There is a link above the recipe to
> add it to your favorites. If you are logged in the page should check
> if you have it already saved, than the link should show "Already in
> cookbook" otherwise "Add to favorites". Next step is when you want to
> add it, you have to be logged in, otherwise the login window should
> show up.
>
> The "Add to cookbook" I wanted to do with AJAX in the background.
>
> So I am using
>
> if($this->Auth->user() == null)
> {
> $this->redirect('/users/login');
> }
>
> in my addToFavorites($id) to check if the User is logged in, if not,
> the Login Form shows up above the recipe. But what I actually would
> like to reach is that the recipe doesn't show up at all anymore but
> instead just the Login Form. If you are than logged in, you should be
> seeing the recipe again and the link should have changed.
>
> I suppose it happens, because I am only replacing the content in the
> <div> with AJAX. Is there any chance to stop the AJAX response and
> instead re-load the full page or what would you guys suggest?
>
> Thanks for any advice. Luke
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---