Welcome, Guest. Register Now!
   
Mark Forums Read Mark Forums Read Mark Forums Read


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-22-2008, 04:24 AM
BJM BJM is offline
Junior Member
 
Join Date: Apr 2008
Posts: 8
Default Struggling with a basic "if" statement.

I'm trying to use the HTTP Authentication Adapter.

I can get it to work for a succcessful login, but I can't get it to work for a failed login. It has something to do with my validate code:

PHP Code:
$auth $adapter->authenticate();

if (!
$auth->isValid()) {
  foreach (
$auth->getMessages() as $message) {
      echo 
"$message\n";
  }
  
// $this->_redirect('error/error'); 
  // die("You don't have access");
} else {
      echo 
"you have access";


Seems simple, but it doesn't work. If I leave it as is and the person clicks the "Cancel" button, I get the messages generated from the foreach, but then it shows the rest of the page which the user shouldn't see, since they are not logged in. As you can see by my commented-out lines, I've tried a couple of approaches. The problem with both of these approaches (die and redirecting) is that it seems to somehow break the authentication. If either of these are used instead of being commented out, users don't get prompted for credentials, but instead the die or redirect automatically runs. In other words, if I uncomment the redirect, users get redirected to the error page and never get the chance to enter credentials.

Please help if you can.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-22-2008, 03:08 PM
Ewok's Avatar
Junior Member
 
Join Date: Mar 2008
Location: Colorado SPrings
Posts: 16
Send a message via MSN to Ewok Send a message via Yahoo to Ewok
Default

PHP Code:
        $auth Zend_Auth::getInstance(); 
        if (!
$auth->hasIdentity()) { 
            
$this->_redirect('/auth/login'); 
        } 
That's how I handle it. Hope it helps.
__________________
Give all victory and gain to others
Take all defeat and loss upon yourself
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 11:42 AM.