2006年07月09日

A question for sd_auth

Dozono,

Thanks for the simple authentication component you developed. It's
perfect for a number of scenarios. I'm new to MVC and to CakePHP.
Is there a way to limit the beforeFilter() Auth Check to the /admin
path? I'm attempting to use CAKE_ADMIN. Also, what is the best way
to implement the logout method?

Thanks,

S.S
----------------------------------------------
Dear S.S.

Thank you for you e-mail.
So far, I haven't tested how to limit the beforeFilter() Auth Check.
But I had thought a same thing. I'm definitely sure we need that kind of technique too.

Your idea sounds a right direction to go.

As for a logout method, I have 'users' table, so

= Model =============================
class UsersController extends AppController
{
  function logout(){
   $this->SdAuth->logout();
   $this->redirect("/index.php");
  }
= View ===============================
<a href="/cake(path of cake)/users/logout">logout</a>
====================================

But I'm not sure if this is the best. Tell us your experiment!

Regards,
S.Dozono

----------------------------------------------
Shunro,

Hey, thanks for the tip! That works great. I think I found a workaround to protect /admin:

change the function in app_controller.php to this:

function adminAuth()
{
// Auth Check.
if($this->SdAuth->isloggedin() == FALSE){
$this->layout = "admin_login";
} else {
$this->layout = "admin";
};
}

notice it is now called "adminAuth()" instead of "beforeFilter()".

Then, in my other controllers, in any method for CAKE_ADMIN I add a call to that function before doing anything:

// This is in pages_controller
function admin_index()
{
$this->adminAuth();
}

I think I could have also gotten your original method to work using a sub-domain for the admin panel like: admin.mysite.com

Regards,

Shane






posted by SDozono at 05:35| ロサンゼルス ☀| Comment(1) | TrackBack(0) | CakePHP Controller | このブログの読者になる | 更新情報をチェックする
×

この広告は180日以上新しい記事の投稿がないブログに表示されております。