From de1857388d17eb62c193576d628a074e8ec68b41 Mon Sep 17 00:00:00 2001 From: Ilya Prokopenko Date: Sun, 17 Apr 2022 08:19:31 +0300 Subject: [PATCH] Global: New route for theme reset Will be useful for themes such as "OpenVK Mobile". --- Web/Presenters/UserPresenter.php | 16 ++++++++++++++++ Web/routes.yml | 2 ++ 2 files changed, 18 insertions(+) diff --git a/Web/Presenters/UserPresenter.php b/Web/Presenters/UserPresenter.php index 1eca5f57..b9e8b714 100644 --- a/Web/Presenters/UserPresenter.php +++ b/Web/Presenters/UserPresenter.php @@ -481,6 +481,22 @@ final class UserPresenter extends OpenVKPresenter $this->flashFail("succ", tr("information_-1"), tr("two_factor_authentication_disabled_message")); } + function renderResetThemepack(): void + { + $this->assertNoCSRF(); + + $this->setSessionTheme(Themepacks::DEFAULT_THEME_ID); + + if($this->user) { + $this->willExecuteWriteAction(); + + $this->user->identity->setStyle(Themepacks::DEFAULT_THEME_ID); + $this->user->identity->save(); + } + + $this->redirect("/", static::REDIRECT_TEMPORARY_PRESISTENT); + } + function renderCoinsTransfer(): void { $this->assertUserLoggedIn(); diff --git a/Web/routes.yml b/Web/routes.yml index 90850278..75870591 100644 --- a/Web/routes.yml +++ b/Web/routes.yml @@ -71,6 +71,8 @@ routes: handler: "User->twoFactorAuthSettings" - url: "/settings/2fa/disable" handler: "User->disableTwoFactorAuth" + - url: "/settings/reset_theme" + handler: "User->resetThemepack" - url: "/coins_transfer" handler: "User->coinsTransfer" - url: "/increase_social_credits"