#124 email change, email confirm, password change
This commit is contained in:
parent
d20d7cec32
commit
7dcff1eb37
@ -1 +1 @@
|
||||
Subproject commit 53d3571c5f4be3d64a918b80c62375fe64f3d837
|
||||
Subproject commit 209a86b080deed9247de01acc5012b5df87d9b93
|
||||
@ -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;}
|
||||
|
||||
8
mojotrollz/api/mojotrollz_post_scripts.php
Normal file
8
mojotrollz/api/mojotrollz_post_scripts.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
class mojotrollz_post_scripts {
|
||||
public static function change_email($token_data){
|
||||
$data = \json_decode($token_data['data'],true);
|
||||
$user = \SQL\SYS_SECURITY_USER_BY_ID::Q1(array($data['user']));
|
||||
return \SQL\MOJO_ACCOUNT_CHANGE_EMAIL::QI(array($data['email'],$user['email']),new \SQL\mangos_realm());
|
||||
}
|
||||
}
|
||||
8
mojotrollz/api/qq/MOJO_ACCOUNT_CHANGE_EMAIL.php
Normal file
8
mojotrollz/api/qq/MOJO_ACCOUNT_CHANGE_EMAIL.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
namespace SQL;
|
||||
class MOJO_ACCOUNT_CHANGE_EMAIL extends \SYSTEM\DB\QP {
|
||||
public static function get_class(){return \get_class();}
|
||||
public static function mysql(){return
|
||||
'UPDATE account SET email = ? WHERE email = ?;';
|
||||
}
|
||||
}
|
||||
34
mojotrollz/api/qq/SYS_SECURITY_USER_BY_ID.php
Normal file
34
mojotrollz/api/qq/SYS_SECURITY_USER_BY_ID.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
namespace SQL;
|
||||
|
||||
/**
|
||||
* QQ to check for user by ID
|
||||
*/
|
||||
class SYS_SECURITY_USER_BY_ID extends \SYSTEM\DB\QP {
|
||||
/**
|
||||
* Get Classname of the QQ
|
||||
*
|
||||
* @return string Returns classname
|
||||
*/
|
||||
public static function get_class(){return \get_class();}
|
||||
|
||||
/**
|
||||
* Get QQs PostgreSQL Query String
|
||||
*
|
||||
* @return string Returns PostgreSQL Query String
|
||||
*/
|
||||
public static function pgsql(){return
|
||||
'SELECT id,username,email,joindate,locale,last_active,email_confirmed FROM '.\SYSTEM\SQL\system_user::NAME_PG.
|
||||
' WHERE '.\SYSTEM\SQL\system_user::FIELD_USERNAME.' = $1;';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get QQs MYSQL Query String
|
||||
*
|
||||
* @return string Returns MYSQL Query String
|
||||
*/
|
||||
public static function mysql(){return
|
||||
'SELECT id,username,email,joindate,locale,last_active,email_confirmed FROM '.\SYSTEM\SQL\system_user::NAME_MYS.
|
||||
' WHERE '.\SYSTEM\SQL\system_user::FIELD_ID.' = ?;';
|
||||
}
|
||||
}
|
||||
@ -6,20 +6,11 @@ function init_account_changeemail(){
|
||||
preventSubmit: true,
|
||||
submitError: function (form, event, errors) {},
|
||||
submitSuccess: function($form, event){
|
||||
$.ajax({
|
||||
dataType: "json",
|
||||
url: './api.php',
|
||||
data: {
|
||||
call: 'account',
|
||||
action: 'changeemail',
|
||||
new_email: $('#user_email_new').val(),
|
||||
},
|
||||
success: function (data) {
|
||||
if(data.status){ // reload -> 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();
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -4,7 +4,6 @@
|
||||
<p>You are logged in as <b>${email}</b></p>
|
||||
<p>Your Website Account-Name is: <b>${username}</b></p>
|
||||
<p><a href="#!account(changepassword)">Change Password</a></p>
|
||||
<p><a href="#!account(changeemail)">Change EMail</a></p>
|
||||
${option_confirm_email}
|
||||
</div>
|
||||
</div>
|
||||
@ -0,0 +1 @@
|
||||
<p><a href="#!account(changeemail)">Change EMail</a></p>
|
||||
Loading…
x
Reference in New Issue
Block a user