From 4ca5a738805f7d2badaaec752434ae170f8e28e8 Mon Sep 17 00:00:00 2001 From: Akhil Date: Wed, 29 Nov 2023 17:12:02 +0530 Subject: [PATCH 1/5] Lang as query param --- appinfo/routes.php | 2 +- src/signup/RegistrationForm.vue | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/appinfo/routes.php b/appinfo/routes.php index 5eab965e..338c73f8 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -25,7 +25,7 @@ return ['routes' => [ 'url' => '/issue/submit', 'verb' => 'POST' ], - ['name' => 'account#index', 'url' => '/accounts/{lang}/signup', 'verb' => 'GET'], + ['name' => 'account#index', 'url' => '/accounts/signup', 'verb' => 'GET'], ['name' => 'account#create', 'url' => '/accounts/create', 'verb' => 'POST'], ['name' => 'account#captcha', 'url' => '/accounts/captcha', 'verb' => 'GET'], ['name' => 'account#verify_captcha', 'url' => '/accounts/verify_captcha', 'verb' => 'POST'], diff --git a/src/signup/RegistrationForm.vue b/src/signup/RegistrationForm.vue index 38faebc2..6547d487 100644 --- a/src/signup/RegistrationForm.vue +++ b/src/signup/RegistrationForm.vue @@ -301,7 +301,7 @@ export default { } }, onLanguageChange() { - window.location.href = window.location.origin + '/apps/' + APPLICATION_NAME + '/accounts/' + this.formData.selectedLanguage + '/signup' + window.location.href = `${window.location.origin}/apps/${APPLICATION_NAME}/accounts/signup?lang=${this.formData.selectedLanguage}` }, }, } -- GitLab From 24cdf2dc522a9e7c920ad9a7ac06fb832c7fb0d0 Mon Sep 17 00:00:00 2001 From: Akhil Date: Wed, 29 Nov 2023 17:55:39 +0530 Subject: [PATCH 2/5] Set selected lang in session --- appinfo/routes.php | 2 +- lib/Controller/AccountController.php | 4 ++++ src/signup/RegistrationForm.vue | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/appinfo/routes.php b/appinfo/routes.php index 338c73f8..5eab965e 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -25,7 +25,7 @@ return ['routes' => [ 'url' => '/issue/submit', 'verb' => 'POST' ], - ['name' => 'account#index', 'url' => '/accounts/signup', 'verb' => 'GET'], + ['name' => 'account#index', 'url' => '/accounts/{lang}/signup', 'verb' => 'GET'], ['name' => 'account#create', 'url' => '/accounts/create', 'verb' => 'POST'], ['name' => 'account#captcha', 'url' => '/accounts/captcha', 'verb' => 'GET'], ['name' => 'account#verify_captcha', 'url' => '/accounts/verify_captcha', 'verb' => 'POST'], diff --git a/lib/Controller/AccountController.php b/lib/Controller/AccountController.php index 505831be..8409d1df 100644 --- a/lib/Controller/AccountController.php +++ b/lib/Controller/AccountController.php @@ -30,6 +30,8 @@ class AccountController extends Controller { private $session; private $userSession; private $urlGenerator; + private const SELECTED_LANGUAGE_KEY = 'selected_language'; + public function __construct( $AppName, IRequest $request, @@ -62,6 +64,8 @@ class AccountController extends Controller { if ($this->userSession->isLoggedIn()) { return new RedirectResponse($this->urlGenerator->linkToDefaultPageUrl()); } + + $this->session->set(self::SELECTED_LANGUAGE_KEY, $lang); return new TemplateResponse( Application::APP_ID, 'signup', diff --git a/src/signup/RegistrationForm.vue b/src/signup/RegistrationForm.vue index 6547d487..38faebc2 100644 --- a/src/signup/RegistrationForm.vue +++ b/src/signup/RegistrationForm.vue @@ -301,7 +301,7 @@ export default { } }, onLanguageChange() { - window.location.href = `${window.location.origin}/apps/${APPLICATION_NAME}/accounts/signup?lang=${this.formData.selectedLanguage}` + window.location.href = window.location.origin + '/apps/' + APPLICATION_NAME + '/accounts/' + this.formData.selectedLanguage + '/signup' }, }, } -- GitLab From 773717fa82518575eb98649226ed03bca9b742f1 Mon Sep 17 00:00:00 2001 From: Akhil Date: Wed, 29 Nov 2023 18:54:18 +0530 Subject: [PATCH 3/5] Set HTTP_ACCEPT_LANGUAGE --- lib/Controller/AccountController.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/Controller/AccountController.php b/lib/Controller/AccountController.php index 8409d1df..7680b3e4 100644 --- a/lib/Controller/AccountController.php +++ b/lib/Controller/AccountController.php @@ -65,7 +65,8 @@ class AccountController extends Controller { return new RedirectResponse($this->urlGenerator->linkToDefaultPageUrl()); } - $this->session->set(self::SELECTED_LANGUAGE_KEY, $lang); + $_SERVER['HTTP_ACCEPT_LANGUAGE'] = $lang; + return new TemplateResponse( Application::APP_ID, 'signup', @@ -136,6 +137,7 @@ class AccountController extends Controller { $response->setData(['message' => $e->getMessage(), 'success' => false]); $response->setStatus(500); } + $this->session->remove('captcha_verified'); return $response; } /** -- GitLab From 52342ec714fef9b1436ef969ca5bbb859bf8919f Mon Sep 17 00:00:00 2001 From: Akhil Date: Fri, 1 Dec 2023 13:22:01 +0530 Subject: [PATCH 4/5] Remove unused const --- lib/Controller/AccountController.php | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/Controller/AccountController.php b/lib/Controller/AccountController.php index 7680b3e4..80241f7f 100644 --- a/lib/Controller/AccountController.php +++ b/lib/Controller/AccountController.php @@ -30,7 +30,6 @@ class AccountController extends Controller { private $session; private $userSession; private $urlGenerator; - private const SELECTED_LANGUAGE_KEY = 'selected_language'; public function __construct( $AppName, -- GitLab From dae76279dab9932a255968192775566cab5aecd7 Mon Sep 17 00:00:00 2001 From: Akhil Date: Mon, 4 Dec 2023 19:12:26 +0530 Subject: [PATCH 5/5] captcha verified check as const --- lib/Controller/AccountController.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/Controller/AccountController.php b/lib/Controller/AccountController.php index 80241f7f..9bbebb5f 100644 --- a/lib/Controller/AccountController.php +++ b/lib/Controller/AccountController.php @@ -31,6 +31,8 @@ class AccountController extends Controller { private $userSession; private $urlGenerator; + private const CAPTCHA_VERIFIED_CHECK = 'captcha_verified'; + public function __construct( $AppName, IRequest $request, @@ -90,7 +92,7 @@ class AccountController extends Controller { $response = new DataResponse(); - if(!$this->session->get('captcha_verified')) { + if(!$this->session->get(self::CAPTCHA_VERIFIED_CHECK)) { $response->setData(['message' => 'Captcha is not verified!', 'success' => false]); $response->setStatus(400); return $response; @@ -136,7 +138,7 @@ class AccountController extends Controller { $response->setData(['message' => $e->getMessage(), 'success' => false]); $response->setStatus(500); } - $this->session->remove('captcha_verified'); + $this->session->remove(self::CAPTCHA_VERIFIED_CHECK); return $response; } /** @@ -209,7 +211,7 @@ class AccountController extends Controller { $response->setStatus(400); if ($captchaResult === $captchaInput) { $this->session->remove('captcha_result'); - $this->session->set('captcha_verified', true); + $this->session->set(self::CAPTCHA_VERIFIED_CHECK, true); $response->setStatus(200); } return $response; -- GitLab