diff --git a/public/static/js/account/account.js b/public/static/js/account/account.js deleted file mode 100644 index 8ee7b1f..0000000 --- a/public/static/js/account/account.js +++ /dev/null @@ -1,7 +0,0 @@ -(function () { - var form = document.getElementById('accountForm'); - - MapGuesser.toggleFormSubmitButtonDisableOnChange(form, ['password_new', 'password_new_confirm']) - - MapGuesser.setOnsubmitForForm(form); -})(); diff --git a/public/static/js/account/delete.js b/public/static/js/account/delete.js deleted file mode 100644 index 60e9aca..0000000 --- a/public/static/js/account/delete.js +++ /dev/null @@ -1,5 +0,0 @@ -(function () { - var form = document.getElementById('deleteAccountForm'); - - MapGuesser.setOnsubmitForForm(form, '/'); -})(); diff --git a/public/static/js/login/google_signup.js b/public/static/js/login/google_signup.js index 063f57c..6ee6e07 100644 --- a/public/static/js/login/google_signup.js +++ b/public/static/js/login/google_signup.js @@ -1,16 +1,4 @@ (function () { - var form = document.getElementById('googleSignupForm'); - - form.onsubmit = function (e) { - document.getElementById('loading').style.visibility = 'visible'; - - e.preventDefault(); - - MapGuesser.httpRequest('POST', form.action, function () { - window.location.replace('/'); - }); - }; - document.getElementById('cancelGoogleSignupButton').onclick = function () { document.getElementById('loading').style.visibility = 'visible'; diff --git a/public/static/js/login/login.js b/public/static/js/login/login.js deleted file mode 100644 index cb97b3c..0000000 --- a/public/static/js/login/login.js +++ /dev/null @@ -1,43 +0,0 @@ -(function () { - var form = document.getElementById('loginForm'); - - form.onsubmit = function (e) { - document.getElementById('loading').style.visibility = 'visible'; - - e.preventDefault(); - - var formData = new FormData(form); - - MapGuesser.httpRequest('POST', form.action, function () { - if (this.response.error) { - if (this.response.error === 'user_not_found') { - window.location.replace('/signup'); - return; - } - - var errorText; - switch (this.response.error) { - case 'password_too_short': - errorText = 'The given password is too short. Please choose a password that is at least 6 characters long!' - break; - case 'user_not_active': - errorText = 'User found with the given email address, but the account is not activated. Please check your email and click on the activation link!'; - break; - case 'password_not_match': - errorText = 'The given password is wrong.' - break; - } - - document.getElementById('loading').style.visibility = 'hidden'; - - var loginFormError = document.getElementById('loginFormError'); - loginFormError.style.display = 'block'; - loginFormError.innerHTML = errorText; - - return; - } - - window.location.replace('/'); - }, formData); - }; -})(); diff --git a/public/static/js/login/signup.js b/public/static/js/login/signup.js index 89e4209..f130afb 100644 --- a/public/static/js/login/signup.js +++ b/public/static/js/login/signup.js @@ -1,52 +1,4 @@ (function () { - var form = document.getElementById('signupForm'); - - form.onsubmit = function (e) { - document.getElementById('loading').style.visibility = 'visible'; - - e.preventDefault(); - - var formData = new FormData(form); - - MapGuesser.httpRequest('POST', form.action, function () { - if (this.response.error) { - if (this.response.error === 'user_found') { - window.location.replace('/'); - return; - } - - var errorText; - switch (this.response.error) { - case 'email_not_valid': - errorText = 'The given email address is not valid.' - break; - case 'password_too_short': - errorText = 'The given password is too short. Please choose a password that is at least 6 characters long!' - break; - case 'passwords_not_match': - errorText = 'The given passwords do not match.' - break; - case 'user_found_user_not_active': - errorText = 'There is a user already registered with the given email address. Please check your email and click on the activation link!'; - break; - case 'user_found_password_not_match': - errorText = 'There is a user already registered with the given email address, but the given password is wrong.' - break; - } - - document.getElementById('loading').style.visibility = 'hidden'; - - var signupFormError = document.getElementById('signupFormError'); - signupFormError.style.display = 'block'; - signupFormError.innerHTML = errorText; - - return; - } - - window.location.replace('/signup/success'); - }, formData); - }; - var resetSignupButton = document.getElementById('resetSignupButton'); if (resetSignupButton) { resetSignupButton.onclick = function () { diff --git a/src/Controller/LoginController.php b/src/Controller/LoginController.php index c0c740f..82592c2 100644 --- a/src/Controller/LoginController.php +++ b/src/Controller/LoginController.php @@ -107,7 +107,7 @@ class LoginController if ($user === null) { if (strlen($this->request->post('password')) < 6) { - $data = ['error' => 'password_too_short']; + $data = ['error' => ['errorText' => 'The given password is too short. Please choose a password that is at least 6 characters long!']]; return new JsonContent($data); } @@ -116,17 +116,17 @@ class LoginController $this->request->session()->set('tmp_user_data', ['email' => $this->request->post('email'), 'password_hashed' => $tmpUser->getPassword()]); - $data = ['error' => 'user_not_found']; + $data = ['redirect' => ['target' => '/' . \Container::$routeCollection->getRoute('signup')->generateLink()]]; return new JsonContent($data); } if (!$user->getActive()) { - $data = ['error' => 'user_not_active']; + $data = ['error' => ['errorText' => 'User found with the given email address, but the account is not activated. Please check your email and click on the activation link!']]; return new JsonContent($data); } if (!$user->checkPassword($this->request->post('password'))) { - $data = ['error' => 'password_not_match']; + $data = ['error' => ['errorText' => 'The given password is wrong.']]; return new JsonContent($data); } @@ -186,7 +186,7 @@ class LoginController public function signup(): IContent { if ($this->request->user() !== null) { - $data = ['error' => 'logged_in']; + $data = ['redirect' => ['target' => '/' . \Container::$routeCollection->getRoute('home')->generateLink()]]; return new JsonContent($data); } @@ -195,21 +195,21 @@ class LoginController if ($user !== null) { if ($user->getActive()) { if (!$user->checkPassword($this->request->post('password'))) { - $data = ['error' => 'user_found_password_not_match']; + $data = ['error' => ['errorText' => 'There is a user already registered with the given email address, but the given password is wrong.']]; return new JsonContent($data); } $this->request->setUser($user); - $data = ['error' => 'user_found']; + $data = ['redirect' => ['target' => '/' . \Container::$routeCollection->getRoute('index')->generateLink()]]; } else { - $data = ['error' => 'user_found_user_not_active']; + $data = ['error' => ['errorText' => 'There is a user already registered with the given email address. Please check your email and click on the activation link!']]; } return new JsonContent($data); } if (filter_var($this->request->post('email'), FILTER_VALIDATE_EMAIL) === false) { - $data = ['error' => 'email_not_valid']; + $data = ['error' => ['errorText' => 'The given email address is not valid.']]; return new JsonContent($data); } @@ -220,17 +220,17 @@ class LoginController $tmpUser->setPassword($tmpUserData['password_hashed']); if (!$tmpUser->checkPassword($this->request->post('password'))) { - $data = ['error' => 'passwords_not_match']; + $data = ['error' => ['errorText' => 'The given passwords do not match.']]; return new JsonContent($data); } } else { if (strlen($this->request->post('password')) < 6) { - $data = ['error' => 'password_too_short']; + $data = ['error' => ['errorText' => 'The given password is too short. Please choose a password that is at least 6 characters long!']]; return new JsonContent($data); } if ($this->request->post('password') !== $this->request->post('password_confirm')) { - $data = ['error' => 'passwords_not_match']; + $data = ['error' => ['errorText' => 'The given passwords do not match.']]; return new JsonContent($data); } } diff --git a/views/account/account.php b/views/account/account.php index 67469cc..dd3c698 100644 --- a/views/account/account.php +++ b/views/account/account.php @@ -1,13 +1,8 @@ -

Account

-
+
diff --git a/views/account/delete.php b/views/account/delete.php index 461218d..75deec5 100644 --- a/views/account/delete.php +++ b/views/account/delete.php @@ -1,13 +1,8 @@ -

Delete account

- +

Are you sure you want to delete your account? This cannot be undone!

diff --git a/views/admin/map_editor.php b/views/admin/map_editor.php index 5b8d74a..0e58851 100644 --- a/views/admin/map_editor.php +++ b/views/admin/map_editor.php @@ -50,7 +50,7 @@ $jsFiles = [