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 | このブログの読者になる | 更新情報をチェックする
この記事へのコメント
@Shunro - Thanks again for your assistance. Perhaps this will be useful to someone else as well. I have posted a full explanation of my implementation of sd_auth on my blog. ( http://www.shepherdweb.com/2006/07/14/single-user-admin-area-authentication-with-cakephp/ )By the way, on your English translation on Excite: it does not translate the submit buttons on the comment form. I can't tell which button does what.
Posted by Shane Shepherd at 2006年07月15日 23:32
コメントを書く
お名前: [必須入力]

メールアドレス:

ホームページアドレス:

コメント: [必須入力]

認証コード: [必須入力]


※画像の中の文字を半角で入力してください。

この記事へのトラックバック
手(パー)To make a comment: Please type your name and comment. at the validation field box, type 'cakephp'. And there two glay buttons. "Preview"/"Submit". Thank you!
×

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