#124 change password tbc account
This commit is contained in:
parent
999e7e7a6c
commit
5af5ab01d7
@ -29,9 +29,17 @@ class api_mojotrollz extends \SYSTEM\API\api_system {
|
||||
throw new ERROR("Account creation failed. Retry later.");}
|
||||
return JsonResult::ok();
|
||||
}
|
||||
|
||||
|
||||
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_change_password_wow($account, $old_wow_password_sha1, $new_wow_password_sha1){
|
||||
if(!\SYSTEM\SECURITY\security::isLoggedIn()){
|
||||
throw new \SYSTEM\LOG\ERROR('You need to be logged in to change your WoW Account\'s Password.');}
|
||||
$user = \SYSTEM\SECURITY\security::getUser();
|
||||
if(!$user->email_confirmed && $user->username != $account){
|
||||
throw new \SYSTEM\LOG\ERROR('You need to confirm your EMail to change this WoW Account\'s Password.');}
|
||||
return self::wow_account_change_password($account,$old_wow_password_sha1,$new_wow_password_sha1,$user->email);}
|
||||
|
||||
public static function call_account_action_change_email($new_email){
|
||||
return \SYSTEM\SECURITY\security::change_email($new_email,'mojotrollz_post_scripts::change_email');}
|
||||
@ -40,6 +48,8 @@ class api_mojotrollz extends \SYSTEM\API\api_system {
|
||||
return \SQL\MOJO_ACCOUNT_AVAILABLE::Q1(array($username), new \SQL\mangos_realm())['count'] == 0;}
|
||||
private static function wow_account_register($username,$email,$password){
|
||||
return \SQL\MOJO_ACCOUNT_REGISTER::QI(array($username,$email,$password), new \SQL\mangos_realm());}
|
||||
private static function wow_account_change_password($account,$old_wow_password_sha1,$new_wow_password_sha1,$email){
|
||||
return \SQL\MOJO_ACCOUNT_CHANGE_PASSWORD::QI(array($new_wow_password_sha1,$account,$old_wow_password_sha1,$email), new \SQL\mangos_realm()) ? JsonResult::ok() : JsonResult::fail();;}
|
||||
|
||||
public static function call_tbc_action_item($id){
|
||||
return \JsonResult::toString(\SQL\TBC_ITEM::Q1(array($id),new \SQL\mangos_one_world()));}
|
||||
|
||||
8
mojotrollz/api/qq/MOJO_ACCOUNT_CHANGE_PASSWORD.php
Normal file
8
mojotrollz/api/qq/MOJO_ACCOUNT_CHANGE_PASSWORD.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
namespace SQL;
|
||||
class MOJO_ACCOUNT_CHANGE_PASSWORD extends \SYSTEM\DB\QP {
|
||||
public static function get_class(){return \get_class();}
|
||||
public static function mysql(){return
|
||||
'UPDATE account SET sha_pass_hash = ?, v = NULL, s = NULL WHERE username = ? AND sha_pass_hash = ? AND email = ?;';
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,5 @@
|
||||
<div class="row-fluid">
|
||||
<div class="col-md-12">
|
||||
<p style="padding-top: 10px;"><a href="#!account(tbc_new)"><b>New Account</b></a></p>
|
||||
<p style="padding-top: 10px;"><a href="#!account(tbc_new)"><b>New WoW TBC Account</b></a></p>
|
||||
</div>
|
||||
</div>
|
||||
34
mojotrollz/page/account_tbc_account/account_tbc_account.php
Normal file
34
mojotrollz/page/account_tbc_account/account_tbc_account.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
class account_tbc_account implements \SYSTEM\PAGE\Page {
|
||||
var $account = NULL;
|
||||
public function __construct($account) {
|
||||
$this->account = $account;
|
||||
}
|
||||
public static function title(){
|
||||
return \SYSTEM\PAGE\text::get('title_account');}
|
||||
public static function meta(){
|
||||
return \SYSTEM\PAGE\text::tag('meta_account');}
|
||||
public static function js(){
|
||||
return array(new \PPAGE('account_tbc_account/js/account_tbc_account.js'));}
|
||||
public function html(){
|
||||
$vars = \SYSTEM\PAGE\text::tag('mojotrollz');
|
||||
|
||||
if(!\SYSTEM\SECURITY\security::isLoggedIn()){
|
||||
return \SYSTEM\PAGE\replace::replaceFile((new PPAGE('default_account/tpl/account_login.tpl'))->SERVERPATH(), $vars);}
|
||||
|
||||
$user = \SYSTEM\SECURITY\security::getUser();
|
||||
if(!$user->email_confirmed && $user->username != $this->account){
|
||||
$this->account = $user->username;}
|
||||
|
||||
$vars['account'] = $this->account;
|
||||
$vars['account_changepassword'] = $user->email_confirmed ? \SYSTEM\PAGE\replace::replaceFile((new PPAGE('account_tbc_account/tpl/account_tbc_changepassword.tpl'))->SERVERPATH(),$vars) : '';
|
||||
$vars['wow_characters'] = '';
|
||||
$res = \SQL\MOJO_ACCOUNT_CHARACTERS::QQ(array($user->email,$this->account));
|
||||
while($row = $res->next()){
|
||||
$row['online'] = $row['online'] == 1 ? 'online' : 'offline';
|
||||
$vars['wow_characters'] .= \SYSTEM\PAGE\replace::replaceFile((new PPAGE('account_tbc_account/tpl/wow_character.tpl'))->SERVERPATH(), $row);}
|
||||
return \SYSTEM\PAGE\replace::replaceFile((new PPAGE('account_tbc_account/tpl/account_tbc_account.tpl'))->SERVERPATH(), $vars);
|
||||
}
|
||||
|
||||
public static function css() {return array();}
|
||||
}
|
||||
3
mojotrollz/page/account_tbc_account/autoload.inc
Normal file
3
mojotrollz/page/account_tbc_account/autoload.inc
Normal file
@ -0,0 +1,3 @@
|
||||
<?php
|
||||
\SYSTEM\autoload::registerFolder(dirname(__FILE__));
|
||||
\SYSTEM\autoload::registerFolder(dirname(__FILE__).'/qq','SQL');
|
||||
@ -0,0 +1,20 @@
|
||||
function init_account_tbc_account(){
|
||||
$("#account_menu li").removeClass("active");
|
||||
$('#li_tbc').addClass('active');
|
||||
|
||||
$("#login_form input").not("[type=submit]").jqBootstrapValidation({
|
||||
preventSubmit: true,
|
||||
submitError: function($form, event, errors) {},
|
||||
submitSuccess: function($form, event){
|
||||
system.account_login($('#bt_login_user').val(),$('#bt_login_password').val(),function(data){
|
||||
if(data.status){
|
||||
$('.help-block').html("Login successfull.</br>");
|
||||
location.reload(true);
|
||||
} else {
|
||||
$('.help-block').html("Login not successfull.</br> User & Password combination wrong.");
|
||||
}
|
||||
});
|
||||
event.preventDefault();
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
namespace SQL;
|
||||
class MOJO_ACCOUNT_CHARACTERS extends \SYSTEM\DB\QP {
|
||||
public static function get_class(){return \get_class();}
|
||||
public static function mysql(){return
|
||||
'SELECT name, level, online'.
|
||||
' FROM mangos_one_chars.characters as chars'.
|
||||
' LEFT JOIN mangos_one_realm.account as accounts ON chars.account = accounts.id'.
|
||||
' WHERE UPPER(email) = UPPER(?) AND UPPER(username) = UPPER(?);';
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading"><h4>TBC WoW Account <b>${account}</b></h4></div>
|
||||
<div class="panel-body">
|
||||
<div class="row-fluid">
|
||||
<div class="col-md-6"><b>Character</b></div>
|
||||
<div class="col-md-3"><b>Level</b></div>
|
||||
<div class="col-md-3"><b>Online</b></div>
|
||||
</div>
|
||||
${wow_characters}
|
||||
${account_changepassword}
|
||||
</div>
|
||||
</div>
|
||||
@ -0,0 +1,5 @@
|
||||
<div class="row-fluid">
|
||||
<div class="col-md-12">
|
||||
<p style="padding-top: 10px;"><a href="#!account(tbc_changepassword);account.${account}"><b>Change Account's Password</b></a></p>
|
||||
</div>
|
||||
</div>
|
||||
@ -0,0 +1,5 @@
|
||||
<div class="row-fluid">
|
||||
<div class="col-md-6">${name}</div>
|
||||
<div class="col-md-3">${level}</div>
|
||||
<div class="col-md-3">${online}</div>
|
||||
</div>
|
||||
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
class account_tbc_changepassword implements \SYSTEM\PAGE\Page {
|
||||
var $account = NULL;
|
||||
public function __construct($account) {
|
||||
$this->account = $account;}
|
||||
public static function title(){
|
||||
return \SYSTEM\PAGE\text::get('title_account');}
|
||||
public static function meta(){
|
||||
return \SYSTEM\PAGE\text::tag('meta_account');}
|
||||
public static function js(){
|
||||
return array(new \PPAGE('account_tbc_changepassword/js/account_tbc_changepassword.js'));}
|
||||
public function html(){
|
||||
$vars = \SYSTEM\PAGE\text::tag('mojotrollz');
|
||||
|
||||
if(!\SYSTEM\SECURITY\security::isLoggedIn()){
|
||||
return \SYSTEM\PAGE\replace::replaceFile((new PPAGE('default_account/tpl/account_login.tpl'))->SERVERPATH(), $vars);}
|
||||
|
||||
$user = \SYSTEM\SECURITY\security::getUser();
|
||||
if(!$user->email_confirmed && $user->username != $this->account){
|
||||
$this->account = $user->username;}
|
||||
|
||||
$vars['account'] = $this->account;
|
||||
return \SYSTEM\PAGE\replace::replaceFile((new PPAGE('account_tbc_changepassword/tpl/account_tbc_changepassword.tpl'))->SERVERPATH(), $vars);
|
||||
}
|
||||
|
||||
public static function css() {return array();}
|
||||
}
|
||||
2
mojotrollz/page/account_tbc_changepassword/autoload.inc
Normal file
2
mojotrollz/page/account_tbc_changepassword/autoload.inc
Normal file
@ -0,0 +1,2 @@
|
||||
<?php
|
||||
\SYSTEM\autoload::registerFolder(dirname(__FILE__));
|
||||
@ -0,0 +1,37 @@
|
||||
function init_account_tbc_changepassword(){
|
||||
$("#account_menu li").removeClass("active");
|
||||
$('#li_account').addClass('active');
|
||||
|
||||
$("#changepassword_user_form input").not("[type=submit]").jqBootstrapValidation({
|
||||
preventSubmit: true,
|
||||
submitError: function (form, event, errors) {},
|
||||
submitSuccess: function($form, event){
|
||||
var account = $('#changepassword_user_form').attr('account');
|
||||
var password_old =$('#user_password_old').val();
|
||||
var password_new =$('#user_password_new2').val();
|
||||
var old_password = $.sha1(account.toUpperCase()+':'+password_old.toUpperCase())
|
||||
var new_password = $.sha1(account.toUpperCase()+':'+password_new.toUpperCase())
|
||||
$.ajax({
|
||||
async: true,
|
||||
url: './api.php',
|
||||
type: 'GET',
|
||||
dataType: 'JSON',
|
||||
data: {
|
||||
call: 'account',
|
||||
action: 'change_password_wow',
|
||||
account: account,
|
||||
old_wow_password_sha1: old_password,
|
||||
new_wow_password_sha1: new_password
|
||||
},
|
||||
success: function(data){
|
||||
if(data.status){
|
||||
$('#changepassword-help-block').html('Changed Password.');
|
||||
} else {
|
||||
$('#changepassword-help-block').html('Could not change Password.');
|
||||
}
|
||||
}
|
||||
});
|
||||
event.preventDefault();
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -0,0 +1,81 @@
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading"><h4>Change WoW TBC Account <b>${account}</b>'s Password</h4></div>
|
||||
<div class="panel-body">
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
<form class="textbox" style="padding:10px" id="changepassword_user_form" account="${account}">
|
||||
<div class="control-group">
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>${basic_password_old}</th>
|
||||
<td style="vertical-align: top; padding-top: 17px;">
|
||||
<div class="control-group controls">
|
||||
<input type="password"
|
||||
size="35"
|
||||
style="margin-bottom: 15px;"
|
||||
id="user_password_old"
|
||||
placeholder="${basic_placeholder_password}"
|
||||
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}"/>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><hr></th>
|
||||
<th><hr></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th style="vertical-align: top; padding-top: 20px;">${basic_password_new}</th>
|
||||
<td>
|
||||
<div class="control-group" id="change_user_password">
|
||||
<div class="control-group controls" style="clear: both">
|
||||
<input type="password"
|
||||
size="35"
|
||||
style="margin-bottom: 15px; float: left;"
|
||||
id="user_password_new1"
|
||||
name="user_password_new1"
|
||||
placeholder="${basic_placeholder_password}"
|
||||
minlength="5"
|
||||
data-validation-minlength-message="${basic_password_short}"
|
||||
required data-validation-required-message="${basic_password_miss}"/>
|
||||
</div>
|
||||
<div class="control-group controls" style="clear: both">
|
||||
<input type="password"
|
||||
size="35"
|
||||
style="margin-bottom: 15px; float: left;"
|
||||
id="user_password_new2"
|
||||
name="user_password_new2"
|
||||
placeholder="${basic_placeholder_password}"
|
||||
data-validation-matches-match="user_password_new1"
|
||||
required data-validation-matches-message="${basic_password_match}"/>
|
||||
<br/>
|
||||
</div>
|
||||
<p class="help-block" style="float: left; margin-top: 3px;"></p>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
<p style="float: left;"><a href="#!account(tbc_account);account.${account}">Back to WoW TBC Account</a></p>
|
||||
</th>
|
||||
<td>
|
||||
<p style="float: right;">
|
||||
<button class="btn-sm btn btn-success" style="clear: left; height: 32px; font-size: 13px;" type="submit" id="login_submit"><span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> ${basic_change_password}</button>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p id="changepassword-help-block" style="float: left; margin-top: 3px;"></p>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="col-md-4" style="padding-top: 10px;">
|
||||
<p>Caution! This function does not change your Website-Account's Password.</p>
|
||||
<p>To change your Website-Accounts Password's visit your <a href="#!account">Account</a>.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -16,4 +16,6 @@ require_once dirname(__FILE__).'/account_changepassword/autoload.inc';
|
||||
require_once dirname(__FILE__).'/account_changeemail/autoload.inc';
|
||||
|
||||
require_once dirname(__FILE__).'/account_tbc/autoload.inc';
|
||||
require_once dirname(__FILE__).'/account_tbc_new/autoload.inc';
|
||||
require_once dirname(__FILE__).'/account_tbc_new/autoload.inc';
|
||||
require_once dirname(__FILE__).'/account_tbc_account/autoload.inc';
|
||||
require_once dirname(__FILE__).'/account_tbc_changepassword/autoload.inc';
|
||||
@ -1,5 +1,5 @@
|
||||
<div class="row-fluid">
|
||||
<div class="col-md-6">${username}</div>
|
||||
<div class="col-md-6"><a href="#!account(tbc_account);account.${username}">${username}</a></div>
|
||||
<div class="col-md-3">${count}</div>
|
||||
<div class="col-md-3">${online}</div>
|
||||
</div>
|
||||
@ -51,4 +51,10 @@ class page_mojotrollz extends \SYSTEM\API\api_default {
|
||||
|
||||
public static function page_account_tbc_new(){
|
||||
return (new account_tbc_new())->html();}
|
||||
|
||||
public static function page_account_tbc_account($account){
|
||||
return (new account_tbc_account($account))->html();}
|
||||
|
||||
public static function page_account_tbc_changepassword($account){
|
||||
return (new account_tbc_changepassword($account))->html();}
|
||||
}
|
||||
@ -15,10 +15,17 @@ 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 (216, 1, 2, 1, 'account_tbc_account', 'account', 'STRING');
|
||||
REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (217, 1, 2, 1, 'account_tbc_changepassword', 'account', '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 (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 (220, 0, 2, 11, 'change_password_wow', 'account', 'STRING');
|
||||
REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (221, 0, 2, 11, 'change_password_wow', 'old_wow_password_sha1', 'STRING');
|
||||
REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (222, 0, 2, 11, 'change_password_wow', 'new_wow_password_sha1', 'STRING');
|
||||
|
||||
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');
|
||||
@ -14,9 +14,11 @@ 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 (24, 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 (25, 1, 'tbc_new', 'account', 20, 1, 1, '#content_account', './?page=account_tbc_new', 'init_account_tbc_new', 'account_tbc_new');
|
||||
REPLACE INTO `system_page` (`id`, `group`, `name`, `state`, `parent_id`, `login`, `type`, `div`, `url`, `func`, `php_class`) VALUES (26, 1, 'tbc_account', 'account', 20, 1, 1, '#content_account', './?page=account_tbc_account&account=${account}', 'init_account_tbc_account', 'account_tbc_account');
|
||||
REPLACE INTO `system_page` (`id`, `group`, `name`, `state`, `parent_id`, `login`, `type`, `div`, `url`, `func`, `php_class`) VALUES (27, 1, 'tbc_changepassword', 'account', 20, 1, 1, '#content_account', './?page=account_tbc_changepassword&account=${account}', 'init_account_tbc_changepassword', 'account_tbc_changepassword');
|
||||
|
||||
REPLACE INTO `system_page` (`id`, `group`, `name`, `state`, `parent_id`, `login`, `type`, `div`, `url`, `func`, `php_class`) VALUES (26, 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 (27, 1, 'register', 'register', -1, 0, 0, '#content', './?page=register', 'init_register', 'default_register');
|
||||
REPLACE INTO `system_page` (`id`, `group`, `name`, `state`, `parent_id`, `login`, `type`, `div`, `url`, `func`, `php_class`) VALUES (28, 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 (29, 1, 'register', 'register', -1, 0, 0, '#content', './?page=register', 'init_register', 'default_register');
|
||||
|
||||
REPLACE INTO `system_page` (`id`, `group`, `name`, `state`, `parent_id`, `login`, `type`, `div`, `url`, `func`, `php_class`) VALUES (30, 1, 'article', 'article', -1, 0, 0, '#content', './?page=article&id=${article}', 'init_article', 'default_article');
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user