From 07e4ba860886f135147fa1fe382adcbb69e639b1 Mon Sep 17 00:00:00 2001 From: theronakpatel Date: Wed, 24 Jul 2024 14:33:30 +0530 Subject: [PATCH 1/4] Change in choosing langugage in singup --- src/signup/RegistrationForm.vue | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/signup/RegistrationForm.vue b/src/signup/RegistrationForm.vue index db414581..2148c409 100644 --- a/src/signup/RegistrationForm.vue +++ b/src/signup/RegistrationForm.vue @@ -212,12 +212,12 @@ 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] - } + const currentURL = window.location.href; + const urlSegments = currentURL.split('/'); + const languages = ['de', 'fr', 'it', 'es', 'en']; + const potentialLang = urlSegments[urlSegments.length - 2]; + + this.formData.selectedLanguage = languages.includes(potentialLang) ? potentialLang : 'en'; }, methods: { validateForm(fieldsToValidate) { -- GitLab From b249525d7189c39dca057c236e1304d64fd83516 Mon Sep 17 00:00:00 2001 From: theronakpatel Date: Wed, 24 Jul 2024 14:35:47 +0530 Subject: [PATCH 2/4] changes --- src/signup/RegistrationForm.vue | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/signup/RegistrationForm.vue b/src/signup/RegistrationForm.vue index 2148c409..16e11405 100644 --- a/src/signup/RegistrationForm.vue +++ b/src/signup/RegistrationForm.vue @@ -212,12 +212,12 @@ export default { }, }, created() { - const currentURL = window.location.href; - const urlSegments = currentURL.split('/'); - const languages = ['de', 'fr', 'it', 'es', 'en']; - const potentialLang = urlSegments[urlSegments.length - 2]; + const currentURL = window.location.href + const urlSegments = currentURL.split('/') + const languages = ['de', 'fr', 'it', 'es', 'en'] + const potentialLang = urlSegments[urlSegments.length - 2] - this.formData.selectedLanguage = languages.includes(potentialLang) ? potentialLang : 'en'; + this.formData.selectedLanguage = languages.includes(potentialLang) ? potentialLang : 'en' }, methods: { validateForm(fieldsToValidate) { -- GitLab From ceeadaa22da40241a551e14da46f237327f0c233 Mon Sep 17 00:00:00 2001 From: theronakpatel Date: Thu, 25 Jul 2024 14:10:31 +0530 Subject: [PATCH 3/4] Loadstate added --- lib/Controller/AccountController.php | 7 +++++-- src/signup/RegistrationForm.vue | 9 ++------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/lib/Controller/AccountController.php b/lib/Controller/AccountController.php index 48d5117f..51041815 100644 --- a/lib/Controller/AccountController.php +++ b/lib/Controller/AccountController.php @@ -26,7 +26,7 @@ use OCP\ISession; use OCP\IURLGenerator; use OCP\IUserSession; use OCP\L10N\IFactory; - +use OCP\AppFramework\Services\IInitialState; class AccountController extends Controller { protected $appName; protected $request; @@ -39,6 +39,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 +54,7 @@ class AccountController extends Controller { IURLGenerator $urlGenerator, ISession $session, IConfig $config, + IInitialState $initialState, ILogger $logger ) { parent::__construct($AppName, $request); @@ -67,6 +69,7 @@ class AccountController extends Controller { $this->urlGenerator = $urlGenerator; $this->logger = $logger; $this->request = $request; + $this->initialState = $initialState; } /** @@ -83,7 +86,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 16e11405..aee692b6 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('/') - const languages = ['de', 'fr', 'it', 'es', 'en'] - const potentialLang = urlSegments[urlSegments.length - 2] - - this.formData.selectedLanguage = languages.includes(potentialLang) ? potentialLang : 'en' + this.formData.selectedLanguage = loadState(this.appName, 'lang') }, methods: { validateForm(fieldsToValidate) { -- GitLab From fa31b2cf919782c3be568a7f0488cedfd08c4318 Mon Sep 17 00:00:00 2001 From: theronakpatel Date: Thu, 25 Jul 2024 14:10:44 +0530 Subject: [PATCH 4/4] Change in code --- lib/Controller/AccountController.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Controller/AccountController.php b/lib/Controller/AccountController.php index 51041815..239a98a3 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; @@ -26,7 +27,7 @@ use OCP\ISession; use OCP\IURLGenerator; use OCP\IUserSession; use OCP\L10N\IFactory; -use OCP\AppFramework\Services\IInitialState; + class AccountController extends Controller { protected $appName; protected $request; -- GitLab