我有一个为游戏启动第三方脚本的用户注册页面,如果用户接受许可(它将设置一个 HTTP 变量),我只希望此页面完成加载。我目前有它提示权限,但正在后台加载页面,我将如何“等待”或“重新加载”页面以重新检查此变量是否已设置?
添加控制器功能
public function add() {
if ($this->User->IGBRequireTrust()) {
if ($this->request->is('post')) {
$this->User->create();
if ($this->User->save($this->request->data)) {
$this->Session->setFlash(__('The user has been saved'));
$this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The user could not be saved. Please, try again.'));
}
}
}
}
上面调用的模型中的公共函数
// Returns TRUE if the user trusts the site, FALSE otherwise.
public function IGBRequireTrust()
{
if($_SERVER['HTTP_EVE_TRUSTED'] != 'yes')
{
echo "<script>CCPEVE.requestTrust('http://*.".$_SERVER['HTTP_HOST']."');</script>";
}
return true;
}
如果页面不接受该权限,则该页面需要重定向回带有会话闪存消息集的索引函数。我尝试在调用 IGBRequireTrust 函数的地方添加一个 else ,但它似乎总是两者兼而有之。
更新:
应用控制器功能
public function beforeFilter() { $this->Auth->allow('index', 'view');
if($this->name == 'Users' && $this->action == 'add'){
//die('correct controller and action');
if(isset($_SERVER['HTTP_EVE_TRUSTED'])){
if($_SERVER['HTTP_EVE_TRUSTED'] != 'yes' && $this->action != 'promptEveTrusted'){
$this->redirect(array('controller'=>'Users', 'action'=>'promptEveTrusted'));
}
} else {
$this->Session->setFlash(__('Registration is only allowed through the EVE in game browser.'));
$this->redirect(array('controller'=>'Users', 'action'=>'index'));
}
//} else {
// die('wrong controller and action');
}
}