I have a user registration page that launches a third party script for a game, i only want this page to finish loading if the user accepts the permission (it will set a HTTP variable). I currently have it prompting for permission but is loading the page in the background, how would i go about "waiting" or "reloading" the page to re-check if this variable is set yet?
Controller function for add
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.'));
}
}
}
}
Public function in Model that is called above
// 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;
}
The page needs to redirect back to the index function with a session flash msg set if they do not accept the permission. I tried adding an else in where it calls the IGBRequireTrust function but it seems to always do both.
UPDATE:
AppController Function
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');
}
}