function grant() { $auth = $this->authenticate(); if (!$auth) { $this->error('401', 'Not logged in.'); return; } if ($auth[2] != 'god') { $this->error('403', 'Applications can only be authenticated via the Koken console.'); return; } $roles = array('read', 'read-write'); if (!in_array($_POST['role'], $roles)) { $this->_error(400, "Incorrect role request. Valid values are \"read\" and \"read-write\"", 'html'); } $_POST['token'] = koken_rand(); $a = new Application(); $a->from_array($_POST, array(), true); $this->redirect('/auth/token:' . $auth[1]); exit; }