diff --git a/lib/Controller/AccountController.php b/lib/Controller/AccountController.php index 48d5117f4a47ec27a6c9868cfd1db627936166af..239a98a307942e5e32cf112f7ea6edf0e3b5c9fa 100644 --- a/lib/Controller/AccountController.php +++ b/lib/Controller/AccountController.php @@ -19,6 +19,7 @@ use OCP\AppFramework\Http; use OCP\AppFramework\Http\DataResponse; use OCP\AppFramework\Http\RedirectResponse; use OCP\AppFramework\Http\TemplateResponse; +use OCP\AppFramework\Services\IInitialState; use OCP\IConfig; use OCP\ILogger; use OCP\IRequest; @@ -39,6 +40,7 @@ class AccountController extends Controller { private $urlGenerator; /** @var IConfig */ private IConfig $config; + private IInitialState $initialState; private const SESSION_USERNAME_CHECK = 'username_check_passed'; private const CAPTCHA_VERIFIED_CHECK = 'captcha_verified'; private ILogger $logger; @@ -53,6 +55,7 @@ class AccountController extends Controller { IURLGenerator $urlGenerator, ISession $session, IConfig $config, + IInitialState $initialState, ILogger $logger ) { parent::__construct($AppName, $request); @@ -67,6 +70,7 @@ class AccountController extends Controller { $this->urlGenerator = $urlGenerator; $this->logger = $logger; $this->request = $request; + $this->initialState = $initialState; } /** @@ -83,7 +87,7 @@ class AccountController extends Controller { } $_SERVER['HTTP_ACCEPT_LANGUAGE'] = $lang; - + $this->initialState->provideInitialState('lang', $lang); return new TemplateResponse( Application::APP_ID, 'signup', diff --git a/src/signup/RegistrationForm.vue b/src/signup/RegistrationForm.vue index db41458181a7987d1039580b701645b1792815d7..aee692b64bc728ea34b13bceb306d9081b8df391 100644 --- a/src/signup/RegistrationForm.vue +++ b/src/signup/RegistrationForm.vue @@ -162,7 +162,7 @@ import Axios from '@nextcloud/axios' import Password from 'vue-password-strength-meter' import { generateUrl } from '@nextcloud/router' - +import { loadState } from '@nextcloud/initial-state' const APPLICATION_NAME = 'ecloud-accounts' export default { @@ -212,12 +212,7 @@ export default { }, }, created() { - const currentURL = window.location.href - const urlSegments = currentURL.split('/') - this.formData.selectedLanguage = 'en' - if (urlSegments.length === 8) { - this.formData.selectedLanguage = urlSegments[urlSegments.length - 2] - } + this.formData.selectedLanguage = loadState(this.appName, 'lang') }, methods: { validateForm(fieldsToValidate) {