#125 login&logut and register fixes, updated system reference
This commit is contained in:
parent
fb379f32c5
commit
968c9579a8
@ -1 +1 @@
|
||||
Subproject commit 55ef099e06745bda131cbc386b115107f3899487
|
||||
Subproject commit 064a84d4655f39ca89f887163c773b94d25399d3
|
||||
@ -11,16 +11,19 @@ class api_mojotrollz extends \SYSTEM\API\api_system {
|
||||
\SYSTEM\LOG\JsonResult::fail();
|
||||
}
|
||||
|
||||
public static function call_mojo_action_register($username, $password, $email, $wowpassword){
|
||||
if(!\SYSTEM\SECURITY\Security::available($username,$email) || !self::wow_username_available($username)){
|
||||
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)) ||
|
||||
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();
|
||||
return JsonResult::ok();
|
||||
}
|
||||
//prevent normal register
|
||||
//public static function call_account_action_create($username, $password_sha, $email, $locale){
|
||||
// return JsonResult::fail();}
|
||||
|
||||
private static function wow_username_available($username){
|
||||
return \SQL\MOJO_ACCOUNT_AVAILABLE::Q1(array($username), new \SQL\mangos_realm())['count'] == 0;}
|
||||
|
||||
@ -6,9 +6,9 @@ class default_beta extends \SYSTEM\PAGE\Page {
|
||||
return \SYSTEM\PAGE\text::tag('meta_beta');}
|
||||
public function html(){
|
||||
$vars = array();
|
||||
if(\SYSTEM\SECURITY\Security::isLoggedIn()){
|
||||
$vars['email'] = \SYSTEM\SECURITY\Security::getUser()->email;
|
||||
$vars['username'] = \SYSTEM\SECURITY\Security::getUser()->username;
|
||||
if(\SYSTEM\SECURITY\security::isLoggedIn()){
|
||||
$vars['email'] = \SYSTEM\SECURITY\security::getUser()->email;
|
||||
$vars['username'] = \SYSTEM\SECURITY\security::getUser()->username;
|
||||
|
||||
$res = \SQL\MOJO_ACCOUNT_MAIN_ACCOUNT::Q1(array($vars['username'],$vars['email']));
|
||||
$res['online'] = $res['online'] == 1 ? 'online' : 'offline';
|
||||
|
||||
@ -7,12 +7,12 @@ function init_beta(){
|
||||
preventSubmit: true,
|
||||
submitError: function($form, event, errors) {},
|
||||
submitSuccess: function($form, event){
|
||||
$.get('./api.php?call=account&action=login&username='+$('#bt_login_user').val()+'&password_sha='+$.sha1($('#bt_login_password').val())+'&password_md5='+$.md5($('#bt_login_password').val()), function (data) {
|
||||
if(data == 1){
|
||||
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.")
|
||||
$('.help-block').html("Login not successfull.</br> User & Password combination wrong.");
|
||||
}
|
||||
});
|
||||
event.preventDefault();
|
||||
@ -23,8 +23,8 @@ function init_beta(){
|
||||
preventSubmit: true,
|
||||
submitError: function($form, event, errors) {},
|
||||
submitSuccess: function($form, event){
|
||||
$.get('./api.php?call=account&action=logout', function (data) {
|
||||
if(data == 1){
|
||||
system.account_logout(function (data) {
|
||||
if(data.status){
|
||||
$('.help-block').html("Logout successfull.</br>");
|
||||
location.reload(true);
|
||||
} else {
|
||||
|
||||
@ -8,11 +8,11 @@ class default_login extends \SYSTEM\PAGE\Page {
|
||||
return array(new \PPAGE('default_login/js/default_login.js'));}
|
||||
public function html(){
|
||||
$vars = \SYSTEM\PAGE\text::tag('mojotrollz');
|
||||
if(!\SYSTEM\SECURITY\Security::isLoggedIn()){
|
||||
if(!\SYSTEM\SECURITY\security::isLoggedIn()){
|
||||
return \SYSTEM\PAGE\replace::replaceFile((new PPAGE('default_login/tpl/loggedout.tpl'))->SERVERPATH(), $vars);}
|
||||
|
||||
$vars['email'] = \SYSTEM\SECURITY\Security::getUser()->email;
|
||||
$vars['username'] = \SYSTEM\SECURITY\Security::getUser()->username;
|
||||
$vars['email'] = \SYSTEM\SECURITY\security::getUser()->email;
|
||||
$vars['username'] = \SYSTEM\SECURITY\security::getUser()->username;
|
||||
|
||||
$res = \SQL\MOJO_ACCOUNT_MAIN_ACCOUNT::Q1(array($vars['username'],$vars['email']));
|
||||
$res['online'] = $res['online'] == 1 ? 'online' : 'offline';
|
||||
|
||||
@ -3,12 +3,12 @@ function init_login(){
|
||||
preventSubmit: true,
|
||||
submitError: function($form, event, errors) {},
|
||||
submitSuccess: function($form, event){
|
||||
$.get('./api.php?call=account&action=login&username='+$('#bt_login_user').val()+'&password_sha='+$.sha1($('#bt_login_password').val())+'&password_md5='+$.md5($('#bt_login_password').val()), function (data) {
|
||||
if(data == 1){
|
||||
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.")
|
||||
$('.help-block').html("Login not successfull.</br> User & Password combination wrong.");
|
||||
}
|
||||
});
|
||||
event.preventDefault();
|
||||
@ -18,9 +18,9 @@ function init_login(){
|
||||
$("#logout_form input").not("[type=submit]").jqBootstrapValidation({
|
||||
preventSubmit: true,
|
||||
submitError: function($form, event, errors) {},
|
||||
submitSuccess: function($form, event){
|
||||
$.get('./api.php?call=account&action=logout', function (data) {
|
||||
if(data == 1){
|
||||
submitSuccess: function($form, event){
|
||||
system.account_logout(function (data) {
|
||||
if(data.status){
|
||||
$('.help-block').html("Logout successfull.</br>");
|
||||
location.reload(true);
|
||||
} else {
|
||||
|
||||
@ -7,7 +7,7 @@ class default_register extends \SYSTEM\PAGE\Page {
|
||||
public function html(){
|
||||
$vars = array();
|
||||
$vars = array_merge($vars,\SYSTEM\PAGE\text::tag('mojotrollz'));
|
||||
return \SYSTEM\PAGE\replace::replaceFile( \SYSTEM\SECURITY\Security::isLoggedIn() ?
|
||||
return \SYSTEM\PAGE\replace::replaceFile( \SYSTEM\SECURITY\security::isLoggedIn() ?
|
||||
(new PPAGE('default_register/tpl/register_loggedin.tpl'))->SERVERPATH() :
|
||||
(new PPAGE('default_register/tpl/default_register.tpl'))->SERVERPATH(), $vars);
|
||||
}
|
||||
|
||||
@ -6,18 +6,17 @@ function init_register(){
|
||||
submitSuccess: function($form, event){
|
||||
var username = $('#register_username').val();
|
||||
var password = $('#user_register_password2').val();
|
||||
var register_data = {
|
||||
call: 'mojo',
|
||||
action: 'register',
|
||||
username: username,
|
||||
password: $.sha1(password),
|
||||
email: $('#register_email').val(),
|
||||
wowpassword: $.sha1(username.toUpperCase()+':'+password.toUpperCase()),
|
||||
}
|
||||
$.ajax({
|
||||
dataType: "json",
|
||||
url: './api.php',
|
||||
data: register_data,
|
||||
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');
|
||||
@ -26,7 +25,6 @@ function init_register(){
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
event.preventDefault();
|
||||
}
|
||||
});
|
||||
|
||||
@ -40,41 +40,35 @@
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>${basic_password}</th>
|
||||
<th style="vertical-align: top; padding-top: 7px;">${basic_password}</th>
|
||||
<td>
|
||||
<div class="control-group" id="user_password">
|
||||
<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_register_password1"
|
||||
name="user_register_password1"
|
||||
placeholder="${basic_placeholder_password}"
|
||||
minlength="5"
|
||||
data-validation-minlength-message="${basic_password_short}"
|
||||
required data-validation-required-message="${basic_password_miss}"/>
|
||||
<br/>
|
||||
</div>
|
||||
<div class="control-group controls" style="clear: both">
|
||||
<input type="password"
|
||||
size="35"
|
||||
style="margin-bottom: 15px; float: left;"
|
||||
id="user_register_password1"
|
||||
name="user_register_password1"
|
||||
placeholder="${basic_placeholder_password}"
|
||||
minlength="5" data-validation-minlength-message="${basic_password_short}"
|
||||
required data-validation-required-message="${basic_password_miss}"/>
|
||||
<br/>
|
||||
</div>
|
||||
</div>
|
||||
<input type="password"
|
||||
size="35"
|
||||
style="margin-bottom: 15px; float: left;"
|
||||
id="user_register_password2"
|
||||
name="user_register_password2"
|
||||
placeholder="${basic_placeholder_password}"
|
||||
data-validation-matches-match="user_register_password1"
|
||||
data-validation-matches-message="${basic_password_match}"/>
|
||||
<br/>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th></th>
|
||||
<td>
|
||||
<div class="control-group" id="user_password2">
|
||||
<div class="control-group controls" style="clear: both">
|
||||
<input type="password"
|
||||
size="35"
|
||||
style="margin-bottom: 15px; float: left;"
|
||||
id="user_register_password2"
|
||||
name="user_register_password2"
|
||||
placeholder="${basic_placeholder_password}"
|
||||
data-validation-matches-match="user_register_password1"
|
||||
data-validation-matches-message="${basic_password_miss}"/>
|
||||
<br/>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
<p style="float: left;"><a href="#!login">Login an existing Account</a></p>
|
||||
|
||||
@ -16,7 +16,7 @@ class saimod_mojotrollz_beta extends \SYSTEM\SAI\SaiModule {
|
||||
|
||||
if($generate){
|
||||
$vars['beta_code'] = \substr(\sha1(\rand(1, 99999)), 1, 6);
|
||||
if(!\SQL\BETA_INSERT_CODE::QI(array($vars['beta_code'], \SYSTEM\SECURITY\Security::getUser()->id))){
|
||||
if(!\SQL\BETA_INSERT_CODE::QI(array($vars['beta_code'], \SYSTEM\SECURITY\security::getUser()->id))){
|
||||
$vars['beta_code'] = 'generate code failed. Retry!';}
|
||||
}
|
||||
|
||||
@ -30,7 +30,7 @@ class saimod_mojotrollz_beta extends \SYSTEM\SAI\SaiModule {
|
||||
|
||||
public static function html_li_menu(){return '<li class=""><a data-toggle="tooltip" data-placement="left" title="Mojotrollz Beta Codes" href="#!mojotrollz_beta"><span class="glyphicon glyphicon-user" aria-hidden="true"></span> Beta</a></li>';}
|
||||
public static function right_public(){return false;}
|
||||
public static function right_right(){return \SYSTEM\SECURITY\Security::check(\SYSTEM\SECURITY\RIGHTS::SYS_SAI);}
|
||||
public static function right_right(){return \SYSTEM\SECURITY\security::check(\SYSTEM\SECURITY\RIGHTS::SYS_SAI);}
|
||||
public static function js(){return array(new \PSAI('saimod_mojotrollz_beta/js/saimod_mojotrollz_beta.js'));}
|
||||
//public static function css(){return array();}
|
||||
}
|
||||
@ -14,7 +14,7 @@ class saimod_mojotrollz_downloads extends \SYSTEM\SAI\SaiModule {
|
||||
return \SYSTEM\PAGE\replace::replaceFile((new \PSAI('saimod_mojotrollz_downloads/tpl/saimod_mojotrollz_downloads.tpl'))->SERVERPATH(),$vars);}
|
||||
public static function html_li_menu(){return '<li class=""><a data-toggle="tooltip" data-placement="left" title="Mojotrollz Downloads" href="#!mojotrollz_downloads"><span class="glyphicon glyphicon-download-alt" aria-hidden="true"></span> Downloads</a></li>';}
|
||||
public static function right_public(){return false;}
|
||||
public static function right_right(){return \SYSTEM\SECURITY\Security::check(\SYSTEM\SECURITY\RIGHTS::SYS_SAI);}
|
||||
public static function right_right(){return \SYSTEM\SECURITY\security::check(\SYSTEM\SECURITY\RIGHTS::SYS_SAI);}
|
||||
|
||||
public static function sai_mod__SAI_saimod_mojotrollz_downloads_action_save($id,$link,$img,$text,$subtext){
|
||||
\SQL\SAIMOD_MOJOTROLLZ_DOWNLOADS_SAVE::QI(array($id,$link,$img,$text,$subtext));
|
||||
|
||||
@ -137,7 +137,7 @@ class saimod_mojotrollz_npc_vendor_template extends \SYSTEM\SAI\SaiModule {
|
||||
}
|
||||
public static function html_li_menu(){return '<li role="separator" class="nav-divider"></li><li><a data-toggle="tooltip" data-placement="left" title="test server: npc_vendor_template" href="#!mojotrollz_npc_vendor_template"><span class="glyphicon glyphicon-th-list" aria-hidden="true"></span> Vendor Template</a></li>';}
|
||||
public static function right_public(){return false;}
|
||||
public static function right_right(){return \SYSTEM\SECURITY\Security::check(\SYSTEM\SECURITY\RIGHTS::SYS_SAI);}
|
||||
public static function right_right(){return \SYSTEM\SECURITY\security::check(\SYSTEM\SECURITY\RIGHTS::SYS_SAI);}
|
||||
public static function js(){return array( \LIB\lib_handlebars::js(),
|
||||
\LIB\lib_wow_tooltips::js(),
|
||||
new \PSAI('saimod_mojotrollz_npc_vendor_template/js/saimod_mojotrollz_npc_vendor_template.js'));}
|
||||
|
||||
@ -16,7 +16,7 @@ class saimod_mojotrollz_server_handling extends \SYSTEM\SAI\SaiModule {
|
||||
return \SYSTEM\PAGE\replace::replaceFile(dirname(__FILE__).'/tpl/main.tpl', $vars);}
|
||||
public static function html_li_menu(){return '<li class=""><a data-toggle="tooltip" data-placement="left" title="Mojotrollz Server" href="#!mojotrollz_server"><span class="glyphicon glyphicon-home" aria-hidden="true"></span> WoW Servers</a></li>';}
|
||||
public static function right_public(){return false;}
|
||||
public static function right_right(){return \SYSTEM\SECURITY\Security::check(\SYSTEM\SECURITY\RIGHTS::SYS_SAI);}
|
||||
public static function right_right(){return \SYSTEM\SECURITY\security::check(\SYSTEM\SECURITY\RIGHTS::SYS_SAI);}
|
||||
public static function js(){return array(new \PSAI('saimod_mojotrollz_server_handling/js/saimod_mojotrollz_server_handling.js'));}
|
||||
//public static function css(){}
|
||||
|
||||
|
||||
@ -17,7 +17,7 @@ class saimod_mojotrollz_servers extends \SYSTEM\SAI\SaiModule {
|
||||
return \SYSTEM\PAGE\replace::replaceFile((new \PSAI('saimod_mojotrollz_servers/tpl/saimod_mojotrollz_servers.tpl'))->SERVERPATH(),$vars);}
|
||||
public static function html_li_menu(){return '<li class=""><a data-toggle="tooltip" data-placement="left" title="Vote Servers" href="#!mojotrollz_servers"><span class="glyphicon glyphicon-stats" aria-hidden="true"></span> Vote Servers</a></li>';}
|
||||
public static function right_public(){return false;}
|
||||
public static function right_right(){return \SYSTEM\SECURITY\Security::check(\SYSTEM\SECURITY\RIGHTS::SYS_SAI);}
|
||||
public static function right_right(){return \SYSTEM\SECURITY\security::check(\SYSTEM\SECURITY\RIGHTS::SYS_SAI);}
|
||||
|
||||
public static function sai_mod__SAI_saimod_mojotrollz_servers_action_visible($id,$visible){
|
||||
\SQL\SAIMOD_MOJOTROLLZ_VISIBLE::QI(array($visible, $id));
|
||||
|
||||
@ -14,7 +14,7 @@ class saimod_mojotrollz_teamspeak extends \SYSTEM\SAI\SaiModule {
|
||||
return \SYSTEM\PAGE\replace::replaceFile(dirname(__FILE__).'/tpl/main.tpl', $vars);}
|
||||
public static function html_li_menu(){return '<li class=""><a data-toggle="tooltip" data-placement="left" title="Mojotrollz Teamspeak" href="#!mojotrollz_teamspeak"><span class="glyphicon glyphicon-headphones" aria-hidden="true"></span> Teamspeak</a></li>';}
|
||||
public static function right_public(){return false;}
|
||||
public static function right_right(){return \SYSTEM\SECURITY\Security::check(\SYSTEM\SECURITY\RIGHTS::SYS_SAI);}
|
||||
public static function right_right(){return \SYSTEM\SECURITY\security::check(\SYSTEM\SECURITY\RIGHTS::SYS_SAI);}
|
||||
public static function js(){return array(new \PSAI('saimod_mojotrollz_teamspeak/js/saimod_mojotrollz_teamspeak.js'));}
|
||||
//public static function css(){}
|
||||
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (27, 0, 2, 11, 'create', 'wow_password', 'STRING');
|
||||
|
||||
REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (200, 0, 2, 11, 'newserver', 'address', 'STRING');
|
||||
REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (205, 0, 2, 11, 'vote', 'server', 'INT');
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user