【问题标题】:Cakephp User management plugin implementationCakephp 用户管理插件实现
【发布时间】:2011-09-14 11:27:17
【问题描述】:

我已经从链接下载了插件 https://github.com/CakeDC/users

按照页面中给出的步骤进行操作。我创建了“用户”和“详细信息”表。我还注册了用户并验证了用户,但是在访问链接 www.mydomain/users/users/login 时,此页面被重定向到 www.mydomain/users/login 显示缺少控制器。我是蛋糕新手,对我来说很难调试。如果有人帮助我,我将不胜感激。


感谢您的回复。

是的,我已经添加了“cake\libs\controller\app_controller.php”文件中给出的代码。为了测试这一点,我刚刚下载了核心文件并在我的本地系统中设置了这些文件。我已将插件“utils”、“search”和“users”放入我的 app/plugins 文件夹并创建了表格。

现在我也可以注册用户但看不到登录页面。 IE。 “在访问链接 www.mydomain/users/users/login 时,此页面被重定向到显示缺少控制器的 www.mydomain/users/login”。

如果我遗漏了什么或者我错了,请告诉我。

谢谢。

【问题讨论】:

    标签: cakephp


    【解决方案1】:

    这看起来像是登录重定向中的问题。

    您是否将 beforeFilter() 配置添加到您的 app_controller 中?

    如果没有,您可能需要添加它。

    以下是您的 app_controller 的示例:

    <?php
        class AppController extends Controller {
            var $components = array('RequestHandler', 'Session', 'Auth');
    
            function beforeFilter(){
                $this->Auth->fields = array('username' => 'email', 'password' => 'passwd');
                $this->Auth->loginAction = array('plugin' => 'users', 'controller' => 'users', 'action' => 'login', 'admin' => false);
                $this->Auth->loginRedirect = '/';
                $this->Auth->logoutRedirect = '/';
                $this->Auth->authError = __('Sorry, but you need to login to access this location.', true);
                $this->Auth->loginError = __('Invalid e-mail / password combination.  Please try again', true);
                $this->Auth->autoRedirect = false;
                $this->Auth->userModel = 'Users.User';
                $this->Auth->userScope = array('User.active' => 1);
            }
        }
    
    ?>
    

    记住 $this->Auth->loginAction MOST 包含 'plugin'=>'users',没有它它将转到 www.mydomain/users/login 而不是 www.mydomain/users/users/login

    【讨论】:

    • 我尝试编辑您的帖子并更正了 beforFilter() -> 应该是 beforeFilter(),但 StackOverflow 认为我的编辑应该至少包含 6 个字符 (?)。
    猜你喜欢
    • 2015-03-23
    • 1970-01-01
    • 1970-01-01
    • 2020-05-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-12
    相关资源
    最近更新 更多