diff --git a/featherbb/Controller/Install.php b/featherbb/Controller/Install.php index e5bd6ee5..1dca18ae 100644 --- a/featherbb/Controller/Install.php +++ b/featherbb/Controller/Install.php @@ -12,6 +12,7 @@ use FeatherBB\Core\Lister; use FeatherBB\Core\Random; use FeatherBB\Core\Utils; +use FeatherBB\Core\Url; use FeatherBB\Middleware\Core; class Install @@ -49,7 +50,7 @@ public function run() $csrf = new \FeatherBB\Middleware\Csrf(); $csrf->generateNewToken(Container::get('request')); - translate(ForumEnv::get('install', 'featherbb', $this->install_lang)); + translate('install', 'featherbb', $this->install_lang); if (Request::isPost() && empty(Input::getParsedBodyParam('choose_lang'))) { $missing_fields = array(); @@ -137,7 +138,7 @@ public function run() return $this->create_config($data); } } else { - $base_url = str_replace('index.php', '', URL::base()); + $base_url = str_replace('index.php', '', Url::base()); $data = array('title' => __('My FeatherBB Forum'), 'description' => __('Description'), 'base_url' => $base_url, @@ -187,7 +188,7 @@ public function create_db(array $data) // Init DB Core::init_db($data); // Load appropriate language - translate(ForumEnv::get('install', 'featherbb', $data['default_lang'])); + translate('install', 'featherbb', $data['default_lang']); // Create tables foreach ($this->model->get_database_scheme() as $table => $sql) { diff --git a/featherbb/Controller/Profile.php b/featherbb/Controller/Profile.php index cf71e0fe..a7c87ce2 100644 --- a/featherbb/Controller/Profile.php +++ b/featherbb/Controller/Profile.php @@ -57,17 +57,16 @@ public function display($req, $res, $args) throw new Error(__('No permission'), 403); } - return $this->model->delete_user($args['id']); - - View::setPageInfo(array( - 'title' => array(Utils::escape(ForumSettings::get('o_board_title')), __('Profile'), __('Confirm delete user')), - 'active_page' => 'profile', - 'username' => $this->model->get_username($args['id']), - 'id' => $args['id'], - )); - - View::addTemplate('profile/delete_user.php')->display(); - + if (Input::post('delete_user_comply')) { + return $this->model->delete_user($args['id']); + } else { + View::setPageInfo(array( + 'title' => array(Utils::escape(ForumSettings::get('o_board_title')), __('Profile'), __('Confirm delete user')), + 'active_page' => 'profile', + 'username' => $this->model->get_username($args['id']), + 'id' => $args['id'], + ))->addTemplate('profile/delete_user.php')->display(); + } } elseif (Input::post('form_sent')) { // Fetch the user group of the user we are editing diff --git a/featherbb/Middleware/Csrf.php b/featherbb/Middleware/Csrf.php index a94a94df..81c5c320 100644 --- a/featherbb/Middleware/Csrf.php +++ b/featherbb/Middleware/Csrf.php @@ -8,6 +8,7 @@ use RuntimeException; use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Message\ResponseInterface; +use FeatherBB\Core\Error; /** * CSRF protection middleware. @@ -317,9 +318,7 @@ public function getFailureCallable() { if (is_null($this->failureCallable)) { $this->failureCallable = function (ServerRequestInterface $request, ResponseInterface $response, $next) { - $body = new \Slim\Http\Body(fopen('php://temp', 'r+')); - $body->write('Failed CSRF check!'); - return $response->withStatus(400)->withHeader('Content-type', 'text/plain')->withBody($body); + throw new Error('Failed CSRF check!', 500); }; } return $this->failureCallable; diff --git a/featherbb/Model/Profile.php b/featherbb/Model/Profile.php index 80d4950c..36ace231 100644 --- a/featherbb/Model/Profile.php +++ b/featherbb/Model/Profile.php @@ -729,9 +729,7 @@ public function delete_user($id) $this->delete_avatar($id); // Regenerate the users info cache - if (!Container::get('cache')->isCached('users_info')) { - Container::get('cache')->store('users_info', Cache::get_users_info()); - } + Container::get('cache')->store('users_info', Cache::get_users_info()); $stats = Container::get('cache')->retrieve('users_info'); diff --git a/featherbb/Model/Register.php b/featherbb/Model/Register.php index c5e93079..196efc93 100644 --- a/featherbb/Model/Register.php +++ b/featherbb/Model/Register.php @@ -156,16 +156,6 @@ public function insert_user($user) $new_uid = DB::get_db()->lastInsertId(ForumSettings::get('db_prefix').'users'); - - if (ForumSettings::get('o_regs_verify') == '0') { - // Regenerate the users info cache - if (!Container::get('cache')->isCached('users_info')) { - Container::get('cache')->store('users_info', Cache::get_users_info()); - } - - $stats = Container::get('cache')->retrieve('users_info'); - } - // If the mailing list isn't empty, we may need to send out some alerts if (ForumSettings::get('o_mailing_list') != '') { // If we previously found out that the email was banned @@ -265,6 +255,9 @@ public function insert_user($user) $jwt = AuthModel::generate_jwt($user_object, $expire); AuthModel::feather_setcookie('Bearer '.$jwt, $expire); + // Refresh cache + Container::get('cache')->store('users_info', Cache::get_users_info()); + Container::get('hooks')->fire('model.register.insert_user'); return Router::redirect(Router::pathFor('home'), __('Reg complete')); diff --git a/featherbb/routes.php b/featherbb/routes.php index 99d5021e..eb6cdcf7 100644 --- a/featherbb/routes.php +++ b/featherbb/routes.php @@ -88,7 +88,7 @@ // Profile routes Route::group('/user', function() { - Route::get('/{id:[0-9]+}', '\FeatherBB\Controller\Profile:display')->setName('userProfile'); + Route::map(['GET', 'POST'], '/{id:[0-9]+}', '\FeatherBB\Controller\Profile:display')->setName('userProfile'); Route::map(['GET', 'POST'], '/{id:[0-9]+}/section/{section}', '\FeatherBB\Controller\Profile:display')->setName('profileSection'); Route::map(['GET', 'POST'], '/{id:[0-9]+}/action/{action}', '\FeatherBB\Controller\Profile:action')->setName('profileAction'); // TODO: Move to another route for non-authed users Route::map(['GET', 'POST'], '/email/{id:[0-9]+}', '\FeatherBB\Controller\Profile:email')->setName('email'); diff --git a/plugins/test/bootstrap.php b/plugins/test/bootstrap.php index 1b122146..55ab4b13 100644 --- a/plugins/test/bootstrap.php +++ b/plugins/test/bootstrap.php @@ -1,5 +1,5 @@