Allow Email checking for account availability

This commit is contained in:
Ulf Gebhardt 2016-05-30 00:03:37 +02:00
parent 88a19b1b98
commit 4e56e2399f
2 changed files with 19 additions and 2 deletions

View File

@ -77,8 +77,12 @@ class Security {
return $_SESSION[\SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_CONFIG_PATH_BASEURL)];}
// Determine if username exists
public static function available($username){
$res = \SYSTEM\SQL\SYS_SECURITY_AVAILABLE::Q1(array($username));
public static function available($username,$email=null){
if($email){
$res = \SYSTEM\SQL\SYS_SECURITY_AVAILABLE_EMAIL::Q1(array($username,$email));
} else {
$res = \SYSTEM\SQL\SYS_SECURITY_AVAILABLE::Q1(array($username));}
if(!$res){
throw new \SYSTEM\LOG\ERRROR("Cannot determine the availability of username!");}
if($res['count'] != 0){

View File

@ -0,0 +1,13 @@
<?php
namespace SYSTEM\SQL;
class SYS_SECURITY_AVAILABLE_EMAIL extends \SYSTEM\DB\QP {
public static function get_class(){return \get_class();}
public static function pgsql(){return
'SELECT COUNT(*) as count FROM '.\SYSTEM\SQL\system_user::NAME_PG.
' WHERE UPPER('.\SYSTEM\SQL\system_user::FIELD_USERNAME.') like UPPER($1) AND UPPER('.\SYSTEM\SQL\system_user::FIELD_EMAIL.') = UPPER($2);';
}
public static function mysql(){return
'SELECT COUNT(*) as count FROM '.\SYSTEM\SQL\system_user::NAME_MYS.
' WHERE UPPER('.\SYSTEM\SQL\system_user::FIELD_USERNAME.') like UPPER(?) AND UPPER('.\SYSTEM\SQL\system_user::FIELD_EMAIL.') = UPPER(?);';
}
}