diff --git a/lib/system b/lib/system index 53d3571..209a86b 160000 --- a/lib/system +++ b/lib/system @@ -1 +1 @@ -Subproject commit 53d3571c5f4be3d64a918b80c62375fe64f3d837 +Subproject commit 209a86b080deed9247de01acc5012b5df87d9b93 diff --git a/mojotrollz/api/api_mojotrollz.php b/mojotrollz/api/api_mojotrollz.php index cb9487f..908e01a 100644 --- a/mojotrollz/api/api_mojotrollz.php +++ b/mojotrollz/api/api_mojotrollz.php @@ -14,31 +14,17 @@ class api_mojotrollz extends \SYSTEM\API\api_system { public static function call_account_action_create($username, $password, $email, $wowpassword){ if(!\SYSTEM\SECURITY\security::available($username,$email) || !self::wow_username_available($username)){ throw new \SYSTEM\LOG\ERROR('EMail is already in use or Username is not available.');} - if( !\SYSTEM\SECURITY\security::create($username, $password, $email, \SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_CONFIG_DEFAULT_LANG)) || !self::wow_account_register($username,$email,$wowpassword)){ throw new ERROR("Account creation failed. Retry later.");} - 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_change_password($old_password_sha1, $new_password_sha1){ + return \SYSTEM\SECURITY\security::change_password($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();} + public static function call_account_action_change_email($new_email){ + return \SYSTEM\SECURITY\security::change_email($new_email,'mojotrollz_post_scripts::change_email');} private static function wow_username_available($username){ return \SQL\MOJO_ACCOUNT_AVAILABLE::Q1(array($username), new \SQL\mangos_realm())['count'] == 0;} diff --git a/mojotrollz/api/mojotrollz_post_scripts.php b/mojotrollz/api/mojotrollz_post_scripts.php new file mode 100644 index 0000000..a0a2ef1 --- /dev/null +++ b/mojotrollz/api/mojotrollz_post_scripts.php @@ -0,0 +1,8 @@ + 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!'); - } + system.account_change_email($('#user_email_new').val(),function (data) { + if(data.status){ + $('#changeemail-help-block').html('EMail sent!'); + }else{ // show errors + $('#changeemail-help-block').html(data.result ? data.result.message : 'Sending EMail failed!'); } }); event.preventDefault(); diff --git a/mojotrollz/page/account_changepassword/js/account_changepassword.js b/mojotrollz/page/account_changepassword/js/account_changepassword.js index c3c165e..7ada222 100644 --- a/mojotrollz/page/account_changepassword/js/account_changepassword.js +++ b/mojotrollz/page/account_changepassword/js/account_changepassword.js @@ -5,24 +5,12 @@ function init_account_changepassword(){ $("#changepassword_user_form input").not("[type=submit]").jqBootstrapValidation({ preventSubmit: true, submitError: function (form, event, errors) {}, - submitSuccess: function($form, event){ - var password_old = $('#user_password_old').val(); - var password_new = $('#user_password_new2').val(); - $.ajax({ - dataType: "json", - url: './api.php', - data: { - call: 'account', - action: 'changepassword', - old_password_sha1: $.sha1(password_old), - new_password_sha1: $.sha1(password_new), - }, - success: function (data) { - if(data.status){ // reload -> 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!'); - } + submitSuccess: function($form, event){ + system.account_change_password($('#user_password_old').val(),$('#user_password_new2').val(),function (data) { + if(data.status){ + $('#changepassword-help-block').html('Changed Password!'); + }else{ // show errors + $('#changepassword-help-block').html(data.result ? data.result.message : 'Password change failed!'); } }); event.preventDefault(); diff --git a/mojotrollz/page/account_website/account_website.php b/mojotrollz/page/account_website/account_website.php index 329bba5..4a75e95 100644 --- a/mojotrollz/page/account_website/account_website.php +++ b/mojotrollz/page/account_website/account_website.php @@ -14,7 +14,9 @@ class account_website implements \SYSTEM\PAGE\Page { $vars['email'] = \SYSTEM\SECURITY\security::getUser()->email; $vars['username'] = \SYSTEM\SECURITY\security::getUser()->username; - $vars['option_confirm_email'] = \SYSTEM\SECURITY\security::getUser()->email_confirmed ? '' : \SYSTEM\PAGE\replace::replaceFile((new PPAGE('account_website/tpl/option_confirm_email.tpl'))->SERVERPATH(),$vars); + $vars['option_confirm_email'] = \SYSTEM\SECURITY\security::getUser()->email_confirmed ? + \SYSTEM\PAGE\replace::replaceFile((new PPAGE('account_website/tpl/option_confirmed_email.tpl'))->SERVERPATH(),$vars) : + \SYSTEM\PAGE\replace::replaceFile((new PPAGE('account_website/tpl/option_confirm_email.tpl'))->SERVERPATH(),$vars); return \SYSTEM\PAGE\replace::replaceFile((new PPAGE('account_website/tpl/account_website.tpl'))->SERVERPATH(), $vars); } diff --git a/mojotrollz/page/account_website/js/account_website.js b/mojotrollz/page/account_website/js/account_website.js index 3d6b282..fae434b 100644 --- a/mojotrollz/page/account_website/js/account_website.js +++ b/mojotrollz/page/account_website/js/account_website.js @@ -1,6 +1,6 @@ function init_account_website(){ $('#link_confirm_email').click(function(){ - system.account_confirm_email($(this).attr('user'),function (data) { + system.account_confirm_email(function (data) { if(data.status){ $('#notice_email_confirm').html("EMail sent"); } else { diff --git a/mojotrollz/page/account_website/tpl/account_website.tpl b/mojotrollz/page/account_website/tpl/account_website.tpl index 5447de1..bbe0573 100644 --- a/mojotrollz/page/account_website/tpl/account_website.tpl +++ b/mojotrollz/page/account_website/tpl/account_website.tpl @@ -4,7 +4,6 @@

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_confirmed_email.tpl b/mojotrollz/page/account_website/tpl/option_confirmed_email.tpl new file mode 100644 index 0000000..3812d9a --- /dev/null +++ b/mojotrollz/page/account_website/tpl/option_confirmed_email.tpl @@ -0,0 +1 @@ +

Change EMail

\ No newline at end of file