From d20d7cec3290e1e5e1b0314e14014ae91a2093cb Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Thu, 15 Dec 2016 01:53:20 +0100 Subject: [PATCH] #124 change website password, change email started (does not effect wow accounts yet) --- mojotrollz/api/api_mojotrollz.php | 15 ++++ .../account_changeemail.php | 19 +++++ .../page/account_changeemail/autoload.inc | 2 + .../js/account_changeemail.js | 28 +++++++ .../tpl/account_changeemail.tpl | 46 +++++++++++ .../account_changepassword.php | 19 +++++ .../page/account_changepassword/autoload.inc | 2 + .../js/account_changepassword.js | 31 +++++++ .../tpl/account_changepassword.tpl | 80 +++++++++++++++++++ .../account_website/tpl/account_website.tpl | 6 +- .../tpl/option_confirm_email.tpl | 2 +- mojotrollz/page/autoload.inc | 4 +- .../page/default_account/tpl/loggedout.tpl | 12 +-- .../tpl/wow_accounts_confirm.tpl | 2 +- .../default_register/js/default_register.js | 42 +++++----- mojotrollz/page/page_mojotrollz.php | 6 ++ mojotrollz/sql/mysql/system_api.sql | 4 + mojotrollz/sql/mysql/system_page.sql | 2 + mojotrollz/sql/mysql/system_text.sql | 5 ++ 19 files changed, 295 insertions(+), 32 deletions(-) create mode 100644 mojotrollz/page/account_changeemail/account_changeemail.php create mode 100644 mojotrollz/page/account_changeemail/autoload.inc create mode 100644 mojotrollz/page/account_changeemail/js/account_changeemail.js create mode 100644 mojotrollz/page/account_changeemail/tpl/account_changeemail.tpl create mode 100644 mojotrollz/page/account_changepassword/account_changepassword.php create mode 100644 mojotrollz/page/account_changepassword/autoload.inc create mode 100644 mojotrollz/page/account_changepassword/js/account_changepassword.js create mode 100644 mojotrollz/page/account_changepassword/tpl/account_changepassword.tpl diff --git a/mojotrollz/api/api_mojotrollz.php b/mojotrollz/api/api_mojotrollz.php index a2c03ff..cb9487f 100644 --- a/mojotrollz/api/api_mojotrollz.php +++ b/mojotrollz/api/api_mojotrollz.php @@ -21,6 +21,21 @@ class api_mojotrollz extends \SYSTEM\API\api_system { return JsonResult::ok(); } + + public static function call_account_action_changepassword($old_password_sha1, $new_password_sha1){ + if(!\SYSTEM\SECURITY\security::isLoggedIn()){ + throw new ERROR("You need to be logged in to change your Password!");} + + return self::call_account_action_change_password(\SYSTEM\SECURITY\security::getUser()->username, $old_password_sha1, $new_password_sha1); + } + + public static function call_account_action_changeemail($new_email){ + if(!\SYSTEM\SECURITY\security::isLoggedIn()){ + throw new ERROR("You need to be logged in to change your EMail!");} + + return self::call_account_action_change_email(\SYSTEM\SECURITY\security::getUser()->username, $new_email); + } + //prevent normal register //public static function call_account_action_create($username, $password_sha, $email, $locale){ // return JsonResult::fail();} diff --git a/mojotrollz/page/account_changeemail/account_changeemail.php b/mojotrollz/page/account_changeemail/account_changeemail.php new file mode 100644 index 0000000..cca7bf6 --- /dev/null +++ b/mojotrollz/page/account_changeemail/account_changeemail.php @@ -0,0 +1,19 @@ +SERVERPATH(), $vars);} + + return \SYSTEM\PAGE\replace::replaceFile((new PPAGE('account_changeemail/tpl/account_changeemail.tpl'))->SERVERPATH(), $vars); + } + + public static function css() {return array();} +} \ No newline at end of file diff --git a/mojotrollz/page/account_changeemail/autoload.inc b/mojotrollz/page/account_changeemail/autoload.inc new file mode 100644 index 0000000..e2c9da4 --- /dev/null +++ b/mojotrollz/page/account_changeemail/autoload.inc @@ -0,0 +1,2 @@ + user will be loged in + $('#changeemail-help-block').html('EMail sent!'); + }else{ // show errors + $('#changeemail-help-block').html(data.result ? data.result.message : 'Sending EMail failed!'); + } + } + }); + event.preventDefault(); + } + }); +} \ No newline at end of file diff --git a/mojotrollz/page/account_changeemail/tpl/account_changeemail.tpl b/mojotrollz/page/account_changeemail/tpl/account_changeemail.tpl new file mode 100644 index 0000000..08cb30c --- /dev/null +++ b/mojotrollz/page/account_changeemail/tpl/account_changeemail.tpl @@ -0,0 +1,46 @@ +
+

Change Account EMail

+
+
+
+
+
+ + + + + + + + + + + +
${basic_email_new} +
+ +
+
+

Back to Website Account

+
+

+ +

+
+
+

+
+
+
+

This function sends an EMail to your old Email-Address with a link to confirm the EMail-Change.

+

The EMail-Change effects the Website Account and all WoW-Accounts.

+
+
+
+
\ No newline at end of file diff --git a/mojotrollz/page/account_changepassword/account_changepassword.php b/mojotrollz/page/account_changepassword/account_changepassword.php new file mode 100644 index 0000000..139196f --- /dev/null +++ b/mojotrollz/page/account_changepassword/account_changepassword.php @@ -0,0 +1,19 @@ +SERVERPATH(), $vars);} + + return \SYSTEM\PAGE\replace::replaceFile((new PPAGE('account_changepassword/tpl/account_changepassword.tpl'))->SERVERPATH(), $vars); + } + + public static function css() {return array();} +} \ No newline at end of file diff --git a/mojotrollz/page/account_changepassword/autoload.inc b/mojotrollz/page/account_changepassword/autoload.inc new file mode 100644 index 0000000..e2c9da4 --- /dev/null +++ b/mojotrollz/page/account_changepassword/autoload.inc @@ -0,0 +1,2 @@ + user will be loged in + $('#changepassword-help-block').html('Changed Password!'); + }else{ // show errors + $('#changepassword-help-block').html(data.result ? data.result.message : 'Password change failed!'); + } + } + }); + event.preventDefault(); + } + }); +} \ No newline at end of file diff --git a/mojotrollz/page/account_changepassword/tpl/account_changepassword.tpl b/mojotrollz/page/account_changepassword/tpl/account_changepassword.tpl new file mode 100644 index 0000000..8cceaf4 --- /dev/null +++ b/mojotrollz/page/account_changepassword/tpl/account_changepassword.tpl @@ -0,0 +1,80 @@ +
+

Change Website Account Password

+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + +
${basic_password_old} +
+ +
+


${basic_password_new} +
+
+ +
+
+ +
+
+

+
+
+

Back to Website Account

+
+

+ +

+
+
+
+
+
+

Caution! This function does not change your WoW-Account's Password.

+

To change your WoW-Accounts Password's visit your WoW-Accounts.

+
+
+
+
\ No newline at end of file diff --git a/mojotrollz/page/account_website/tpl/account_website.tpl b/mojotrollz/page/account_website/tpl/account_website.tpl index fa6044b..5447de1 100644 --- a/mojotrollz/page/account_website/tpl/account_website.tpl +++ b/mojotrollz/page/account_website/tpl/account_website.tpl @@ -1,8 +1,10 @@

Account

- You are logged in as ${email}
- Your Website Account-Name is: ${username}
+

You are logged in as ${email}

+

Your Website Account-Name is: ${username}

+

Change Password

+

Change EMail

${option_confirm_email}
\ No newline at end of file diff --git a/mojotrollz/page/account_website/tpl/option_confirm_email.tpl b/mojotrollz/page/account_website/tpl/option_confirm_email.tpl index c42d772..ae28690 100644 --- a/mojotrollz/page/account_website/tpl/option_confirm_email.tpl +++ b/mojotrollz/page/account_website/tpl/option_confirm_email.tpl @@ -1,2 +1,2 @@ -Request EMail Confirmation +

Request EMail Confirmation

\ No newline at end of file diff --git a/mojotrollz/page/autoload.inc b/mojotrollz/page/autoload.inc index 141d1d8..237adc4 100644 --- a/mojotrollz/page/autoload.inc +++ b/mojotrollz/page/autoload.inc @@ -11,4 +11,6 @@ require_once dirname(__FILE__).'/default_donate/autoload.inc'; require_once dirname(__FILE__).'/default_register/autoload.inc'; require_once dirname(__FILE__).'/account_website/autoload.inc'; -require_once dirname(__FILE__).'/account_tbc/autoload.inc'; \ No newline at end of file +require_once dirname(__FILE__).'/account_tbc/autoload.inc'; +require_once dirname(__FILE__).'/account_changepassword/autoload.inc'; +require_once dirname(__FILE__).'/account_changeemail/autoload.inc'; \ No newline at end of file diff --git a/mojotrollz/page/default_account/tpl/loggedout.tpl b/mojotrollz/page/default_account/tpl/loggedout.tpl index c61871e..10da0b0 100644 --- a/mojotrollz/page/default_account/tpl/loggedout.tpl +++ b/mojotrollz/page/default_account/tpl/loggedout.tpl @@ -17,9 +17,9 @@ style="margin-bottom: 15px;" id="bt_login_user" placeholder="${basic_placeholder_username}" - minlength="3" data-validation-minlength-message="${sai_error_username_short}" - maxlength="16" data-validation-maxlength-message="${sai_error_username_long}" - required data-validation-required-message="${sai_error_username_miss}"/> + minlength="3" data-validation-minlength-message="${basic_username_short}" + maxlength="16" data-validation-maxlength-message="${basic_username_long}" + required data-validation-required-message="${basic_username_miss}"/> @@ -32,9 +32,9 @@ style="margin-bottom: 15px;" id="bt_login_password" placeholder="${basic_placeholder_password}" - minlength="5" data-validation-minlength-message="${sai_error_password_short}" - maxlength="16" data-validation-maxlength-message="${sai_error_password_long}" - required data-validation-required-message="${sai_error_password_miss}"/> + minlength="5" data-validation-minlength-message="${basic_password_short}" + maxlength="16" data-validation-maxlength-message="${basic_password_long}" + required data-validation-required-message="${basic_password_miss}"/> diff --git a/mojotrollz/page/default_account/tpl/wow_accounts_confirm.tpl b/mojotrollz/page/default_account/tpl/wow_accounts_confirm.tpl index e9cd6c4..d55afae 100644 --- a/mojotrollz/page/default_account/tpl/wow_accounts_confirm.tpl +++ b/mojotrollz/page/default_account/tpl/wow_accounts_confirm.tpl @@ -1,5 +1,5 @@
-

To see all your Accounts confirm Your Email!

+

To see all your Accounts confirm Your Email!

\ No newline at end of file diff --git a/mojotrollz/page/default_register/js/default_register.js b/mojotrollz/page/default_register/js/default_register.js index 9fc3e3c..fa5eb68 100644 --- a/mojotrollz/page/default_register/js/default_register.js +++ b/mojotrollz/page/default_register/js/default_register.js @@ -4,28 +4,28 @@ function init_register(){ preventSubmit: true, submitError: function (form, event, errors) {}, submitSuccess: function($form, event){ - var username = $('#register_username').val(); - var password = $('#user_register_password2').val(); - $.ajax({ - dataType: "json", - url: './api.php', - data: { - call: 'account', - action: 'create', - username: username, - password_sha1: $.sha1(password), - email: $('#register_email').val(), - wow_password: $.sha1(username.toUpperCase()+':'+password.toUpperCase()), - }, - success: function (data) { - if(data.status){ // reload -> user will be loged in - system.load('beta'); - }else{ // show errors - $('.help-block').html(data.result.message); - } + var username = $('#register_username').val(); + var password = $('#user_register_password2').val(); + $.ajax({ + dataType: "json", + url: './api.php', + data: { + call: 'account', + action: 'create', + username: username, + password_sha1: $.sha1(password), + email: $('#register_email').val(), + wow_password: $.sha1(username.toUpperCase()+':'+password.toUpperCase()), + }, + success: function (data) { + if(data.status){ // reload -> user will be loged in + system.load('beta'); + }else{ // show errors + $('.help-block').html(data.result.message); } - }); - event.preventDefault(); + } + }); + event.preventDefault(); } }); } \ No newline at end of file diff --git a/mojotrollz/page/page_mojotrollz.php b/mojotrollz/page/page_mojotrollz.php index 3f03f8a..4647214 100644 --- a/mojotrollz/page/page_mojotrollz.php +++ b/mojotrollz/page/page_mojotrollz.php @@ -39,4 +39,10 @@ class page_mojotrollz extends \SYSTEM\API\api_default { public static function page_account_tbc(){ return (new account_tbc())->html();} + + public static function page_account_changepassword(){ + return (new account_changepassword())->html();} + + public static function page_account_changeemail(){ + return (new account_changeemail())->html();} } \ No newline at end of file diff --git a/mojotrollz/sql/mysql/system_api.sql b/mojotrollz/sql/mysql/system_api.sql index 78134f9..5bc04a3 100644 --- a/mojotrollz/sql/mysql/system_api.sql +++ b/mojotrollz/sql/mysql/system_api.sql @@ -12,6 +12,10 @@ REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `na -- REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (210, 1, 3, 1, 'beta', 'key', 'STRING'); REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (215, 1, 2, 1, 'article', 'id', 'STRING'); +REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (220, 0, 2, 11, 'changepassword', 'old_password_sha1', 'STRING'); +REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (221, 0, 2, 11, 'changepassword', 'new_password_sha1', 'STRING'); + +REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (222, 0, 2, 11, 'changeemail', 'new_email', 'EMAIL'); REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (500, 0, 2, 11, 'item', 'id', 'INT'); REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (501, 0, 2, 11, 'itemextendedcost', 'id', 'INT'); \ No newline at end of file diff --git a/mojotrollz/sql/mysql/system_page.sql b/mojotrollz/sql/mysql/system_page.sql index 38adad0..187b364 100644 --- a/mojotrollz/sql/mysql/system_page.sql +++ b/mojotrollz/sql/mysql/system_page.sql @@ -8,6 +8,8 @@ REPLACE INTO `system_page` (`id`, `group`, `name`, `state`, `parent_id`, `login` REPLACE INTO `system_page` (`id`, `group`, `name`, `state`, `parent_id`, `login`, `type`, `div`, `url`, `func`, `php_class`) VALUES (20, 1, 'account', 'account', -1, 0, 0, '#content', './?page=account', 'init_account', 'default_account'); REPLACE INTO `system_page` (`id`, `group`, `name`, `state`, `parent_id`, `login`, `type`, `div`, `url`, `func`, `php_class`) VALUES (21, 1, 'website', 'account', 20, 1, 0, '#content_account', './?page=account_website', 'init_account_website', 'account_website'); REPLACE INTO `system_page` (`id`, `group`, `name`, `state`, `parent_id`, `login`, `type`, `div`, `url`, `func`, `php_class`) VALUES (22, 1, 'tbc', 'account', 20, 1, 1, '#content_account', './?page=account_tbc', 'init_account_tbc', 'account_tbc'); +REPLACE INTO `system_page` (`id`, `group`, `name`, `state`, `parent_id`, `login`, `type`, `div`, `url`, `func`, `php_class`) VALUES (23, 1, 'changepassword', 'account', 20, 1, 1, '#content_account', './?page=account_changepassword', 'init_account_changepassword', 'account_changepassword'); +REPLACE INTO `system_page` (`id`, `group`, `name`, `state`, `parent_id`, `login`, `type`, `div`, `url`, `func`, `php_class`) VALUES (24, 1, 'changeemail', 'account', 20, 1, 1, '#content_account', './?page=account_changeemail', 'init_account_changeemail', 'account_changeemail'); REPLACE INTO `system_page` (`id`, `group`, `name`, `state`, `parent_id`, `login`, `type`, `div`, `url`, `func`, `php_class`) VALUES (25, 1, 'beta', 'beta', -1, 0, 0, '#content', './?page=beta', 'init_beta', 'default_beta'); REPLACE INTO `system_page` (`id`, `group`, `name`, `state`, `parent_id`, `login`, `type`, `div`, `url`, `func`, `php_class`) VALUES (26, 1, 'register', 'register', -1, 0, 0, '#content', './?page=register', 'init_register', 'default_register'); diff --git a/mojotrollz/sql/mysql/system_text.sql b/mojotrollz/sql/mysql/system_text.sql index 8c34d2c..4237627 100644 --- a/mojotrollz/sql/mysql/system_text.sql +++ b/mojotrollz/sql/mysql/system_text.sql @@ -29,6 +29,11 @@ REPLACE INTO `system_text_tag` (`id`, `tag`) VALUES ('basic_password_short', 'mo REPLACE INTO `system_text_tag` (`id`, `tag`) VALUES ('basic_password_long', 'mojotrollz'); REPLACE INTO `system_text_tag` (`id`, `tag`) VALUES ('basic_password_miss', 'mojotrollz'); REPLACE INTO `system_text_tag` (`id`, `tag`) VALUES ('basic_password_match', 'mojotrollz'); +REPLACE INTO `system_text_tag` (`id`, `tag`) VALUES ('basic_password_new', 'mojotrollz'); +REPLACE INTO `system_text_tag` (`id`, `tag`) VALUES ('basic_password_old', 'mojotrollz'); +REPLACE INTO `system_text_tag` (`id`, `tag`) VALUES ('basic_change_password', 'mojotrollz'); +REPLACE INTO `system_text_tag` (`id`, `tag`) VALUES ('basic_change_email', 'mojotrollz'); +REPLACE INTO `system_text_tag` (`id`, `tag`) VALUES ('basic_email_new', 'mojotrollz'); REPLACE INTO `system_text` (`id`, `lang`, `text`, `author`, `author_edit`, `time_create`, `time_edit`) VALUES ('link_facebook', 'enUS', 'https://www.facebook.com/mojotrollz/', 10, 10, '2015-09-17 23:16:50', '2015-09-17 23:16:50'); REPLACE INTO `system_text_tag` (`id`, `tag`) VALUES ('link_facebook', 'link');