WkHtmlToPdf 组件,身份验证问题
我正在尝试使用 WkHtmlToPdf 组件,它当遇到生成 pdf 文件的问题时,似乎是一个不错的工具。
但是 - 我无法让它与身份验证组件一起使用。问题是我总是将登录页面生成为 pdf 格式。我已记录,该操作在 beforeFilter 中是允许的,但它仍然以某种方式妨碍它。
编辑:
AppController:
var $components = array('Auth', 'Session');
function beforeFilter()
{
$this->Auth->logoutRedirect = array('controller' => 'users', 'action' => 'login');
if (!$this->Auth->user())
{
$this->layout = 'login';
}
}
控制器:
var $components = array('WkHtmlToPdf');
function beforeFilter() // I am logged in, so this shouldn't even be needed
{
$this->Auth->allow('pdf');
}
function pdf()
{
$this->WkHtmlToPdf->createPdf();
}
// this function is required for wkhtmltopdf to retrieve
// the viewdump once it's rendered
function getViewDump($fileName)
{
$this->WkHtmlToPdf->getViewDump($fileName);
}
任何帮助将不胜感激, 保罗
I'm trying to use the WkHtmlToPdf Component, it seems like a nice tool when facing the problem of generating pdf files.
However - I can't get it to work with the Auth Component. The problem is that I always get the login page generated to pdf. I'm logged, the action is allowed in beforeFilter and it still somehow gets into the way of it.
EDIT:
AppController:
var $components = array('Auth', 'Session');
function beforeFilter()
{
$this->Auth->logoutRedirect = array('controller' => 'users', 'action' => 'login');
if (!$this->Auth->user())
{
$this->layout = 'login';
}
}
Controller:
var $components = array('WkHtmlToPdf');
function beforeFilter() // I am logged in, so this shouldn't even be needed
{
$this->Auth->allow('pdf');
}
function pdf()
{
$this->WkHtmlToPdf->createPdf();
}
// this function is required for wkhtmltopdf to retrieve
// the viewdump once it's rendered
function getViewDump($fileName)
{
$this->WkHtmlToPdf->getViewDump($fileName);
}
Any help would be greatly appreciated,
Paul
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
事实证明,您必须允许
getViewDump
方法。它似乎不适用于 Auth,但允许每个人使用它并没有威胁,并且它有效。控制器:
It turns out, you have to allow the
getViewDump
method. It doesn't seem to work with Auth, but there is no threat with allowing it for everyone, and it works.controller: