允许CakePHP的特定页面 [英] Allowing a Specific Page in Cakephp

查看:140
本文介绍了允许CakePHP的特定页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道如何让某些控制器的动作非登录的用户。但是,我无法找到如何允许访问特定页面的任何文件。控制器是页面和动作显示。但是,我不想让用户看到所有页面,只是关于页面。

I understand how to allow certain controller actions for non-logged in users. But, I can't find any documentation on how to allow access to specific pages. The controller is pages and the action is display. But, I don't want to allow the user to see all pages, just the about page.

那么,什么是允许的正确途径客人访问了一些,但不是所有的页面?

So, what is the correct way to allow guests access to some, but not all, pages?

推荐答案

我怕你不能这样做,使用标准的函数, AuthComponent 给你。你必须创建自己的逻辑,在 pages_controller 显示操作。

I'm afraid you can't do that using the standard functions that AuthComponent gives you. You have to create your own logic for that in the pages_controller's display action.

喜欢的东西(伪code型)

Something like (pseudo-code style)

# in app/controllers/pages_controller.php
var $allowedPages = array('one', 'two');

function display($page) {
    if(in_array($page, $allowedPages) || $this->User->loggedin) {
        $this->render($page);
    } else {
        $this->render('not_allowed');
    }
}

这篇关于允许CakePHP的特定页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆