Well, I experience unwanted redirects to the login page also. But I can't tell what are the conditions for this bug to happen.
Sorry, I can't imagine why in addition to that you've twice the login param.

Ryan Petrain wrote:
I am looking to control where the person is being redirected to after they login based on what they were trying to access.

I solved this problem by setting a variable $AuthConf = array(...) in app_controller.php and then having the other controllers override that to set the array to values needed for that controller.

I cannot figure out why I am being redirected back to the login page again after Iogin.
the pathe before login looks like:

http://localhost/users/login

when redirected back to the login page it is:

http://localhost/users/login/login

Any ideas?

On 6/30/06, Olivier Percebois-Garve < [EMAIL PROTECTED]> wrote:
"does that mean all the other controllers that do not override this will be redirected to "categories/login" if it is a restricted page?"
Yes, I think so, so how my app is behaving. For instance if I request "posts/index/127" I'm redirected first to categories/login.
I'm not sure if I understand you second question. You want to be always redirect to the same page after login, whatever the restricted page that has been called ?

 


Ryan Petrain wrote:
Olivier,

I have a question about you app_controller.php.

If I understand it right, seeing where you have the beforeFilter set in the main controller, where you set the login to "categories/login" and the redirect to "categories/login"  does that mean all the other controllers that do not override this will be redirected to "categories/login" if it is a restricted page?

How do I set up a generic beforeFilter so that it can be handed in  apage to redirect after the login is sucessful?

Thanx.

On 6/30/06, Ryan Petrain <[EMAIL PROTECTED]> wrote:
Olivier,

I am not getting that error, but when I visit a restricted page it redirects me to the login (good), I login with proper credentials, and then it redirects me to the login again.

Any ideas on what I am still doing wrong?
thanx for all your help so far.



On 6/30/06, Olivier Percebois-Garve < [EMAIL PROTECTED]> wrote:
Ryan, I think you need a before filter, I have this :


    function beforeFilter()
    {
        $auth_conf = array(
        'auto_redirect' => true,
        'login_page' => 'categories/login',
        'logout_page' => 'categories/view',
        'access_page' => 'categories/login',
        'hashkey' => 'MySEcEeTHaSHKeYz');

       
        $this->othAuth->controller = &$this;
        $this->othAuth->init($auth_conf);
        $this->othAuth->check();
    }


Sorry I'm in hurry got to go see Germany win. I'll look at your code later if I can.
If you want you can have a look at how I implemented it in chameleon in cakeforge (take the svn, the package is old and broke)







Ryan Petrain wrote:
Hi Olivier,

This is the user controller that handles the login.  What other code do you need?
class UsersController extends AppController
{
    var $name = "Users";
    var $components = array('othAuth');
    //var $othAuthRestrictions = array('index','view');
    var $othAuthRestrictions = null;
    var $uses = array('User');
   
    function login()
    {
        $this->layout = 'nosearchbar';
        if(isset($this->params['data']))
        {
                //$this->flash(print_r($this->params['data']),'/users/login');
                $auth_num = $this->othAuth->login($this->params['data']['User']);
                $this->set('auth_msg', $this->othAuth->getMsg($auth_num));
        }
    }

    function logout()
    {
            $this->othAuth->logout();
            $this->flash('You are not logged in!','/users/login');
    }
}
?>

On 6/30/06, Olivier Percebois-Garve <[EMAIL PROTECTED] > wrote:
can you paste your code ? (in cakebin for instance)


Ryan Petrain wrote:
Hi Langdon,

Cna you help me get past a raher mundane aspect of using othAuth?
I have added othAuth to my cake install and all appears to be fine.

I try to get to a restricted area and it redirects to the login page.  I enter the login credentials and then I get this error once I click the submit button:

Notice: Trying to get property of non-object in C:\apache2\htdocs\Trans2\app\controllers\components\oth_auth.php on line 109

Fatal error: Call to a member function find() on a non-object in C:\apache2\htdocs\Trans2\app\controllers\components\oth_auth.php on line 109

The login page has access to the  User object.  I have even added the $users = array('User'); to the controller to see if that was what it needed but I still can not get past this.

Any help would be appreciated. thanx.


On 6/30/06, Olivier Percebois-Garve < [EMAIL PROTECTED] > wrote:
Wow. I see that there is more and more othAuth users. I've two issues I'm not sure how to tackle.
Just wanna to know if some peoples are sharing the same concerns (and if crazylegs thought about that for the new version)

1.Sometimes I hit the login page while its seems that I am already logged. if I fill in the right login, then I got back the message
that credentials are wrong. But n fact after that  if I enter manually  the  url of a restricted method, I can access it.
I'm not sure how to reproduce this but it happened often during testing of code in restricted method. maybe it is related to my use
of requestAction.

2. I'd like to gather the name of all the controller having restricted methods, and the names of the restricted methods ($othAuthRestrictions)
in my layout. Basically I'm doing :
if restricted build adminMenu
else build userMenu
Any ideas on how to achieve this ?

olivvv



Langdon Stevenson wrote:
Hi rombeh

I have the following code in the controllers that I want to protect:
(note: extra $helpers and $components have been removed to simplify)

class LeadersController extends AppController





{
   var $name = 'Leaders'; //for php4

   var $helpers = array('othAuth');
   var $components = array('othAuth');
	
   var $othAuthRestrictions = array('index');
	
   function beforeFilter()




   {

     $auth_conf = array('auto_redirect' => true,
     'login_page'  => 'leaders/login',
     'logout_page' => 'leaders/logout',
     'access_page' => '/leaders',
     'hashkey'     => 'mYpERsOnALhaSHkeY',





     'strict_gid_check' => false);
	
     $this->othAuth->controller = &$this;
     $this->othAuth->init($auth_conf);
     $this->othAuth->check();
   }	


   function index ()




   {
     // Action code ...
   }
}


That is all that is required to add to the controller to protect the 
index action, assuming that you have followed the othAuth setup 

instructions and have the required classes and DB tables in place.





As mentioned in my previous post I also have a permission in the 
permission table like this:

INSERT INTO `cake_permissions` VALUES (1,'leaders/index','2006-03-13 

23:19:31','0000-00-00 00:00:00');





And a Groups-Permissions mapping that connects that permission to the 
desired user's group.

As a side note, you have to check that your User has the right group ID 

assigned, and that their Active field is set to "1".





Hope this is useful.

Regards,
Langdon







rombeh wrote:
  
hi Langdon Stevenson,
Can u show me quick walkthrough (place some code too :D) in order to
get it works

thanks
    
  































--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---

Reply via email to