[FIX] bugs login; Wefra is a mix of Wefra and Wodoo which creates a mess; A lot of fixes to come; I am on it (DD)
This commit is contained in:
parent
6edd9145ad
commit
d0f514b9af
@ -1,8 +1,92 @@
|
|||||||
<?php
|
<?php
|
||||||
class ClassUser extends ClassConfig {
|
class ClassUser {
|
||||||
public function __construct(){}
|
public function __construct(){}
|
||||||
public function __destruct(){}
|
public function __destruct(){}
|
||||||
|
|
||||||
|
public function getFeatures($user_id){
|
||||||
|
$this->_userId = $user_id;
|
||||||
|
$oPDOLink = ClassConfig::databaseConnect();
|
||||||
|
|
||||||
|
$sql = "
|
||||||
|
SELECT f.*,
|
||||||
|
(SELECT source FROM core_translation WHERE id=f.url_feature_translation_id) AS url,
|
||||||
|
(SELECT source FROM core_translation WHERE id=f.label_feature_translation_id) AS menu_label
|
||||||
|
FROM useruser_corefeature_rel r
|
||||||
|
INNER JOIN core_feature f
|
||||||
|
ON r.core_feature_id=f.id
|
||||||
|
WHERE r.user_id=:user_id
|
||||||
|
AND f.is_active=TRUE
|
||||||
|
ORDER BY f.priority ASC;
|
||||||
|
";
|
||||||
|
$execSQL = $oPDOLink->prepare($sql);
|
||||||
|
$execSQL->execute(array(':user_id'=>$user_id));
|
||||||
|
$rows = $execSQL->fetchAll(PDO::FETCH_OBJ);
|
||||||
|
return $rows;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function login($post_datas=array()){
|
||||||
|
$this->_postDatas = $post_datas;
|
||||||
|
$oPDOLink = ClassConfig::databaseConnect();
|
||||||
|
|
||||||
|
if($this->_postDatas['formLoginFieldEmail']=='' || $this->_postDatas['formLoginFieldPassword']==''){
|
||||||
|
$message['state'] = 'no_required_fields_filled';
|
||||||
|
$message['css_class'] = 'failed-message';
|
||||||
|
$message['translation_code'] = "message_requiredFieldsNotFilled";
|
||||||
|
return $message;
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql="
|
||||||
|
SELECT uu.id, uu.email, uu.password, uu.firstname, uu.lastname, uu.phone,
|
||||||
|
uu.core_lang_id, uu.core_country_id, uu.core_currency_id,
|
||||||
|
uu.is_backend_access, uu.is_employee, uu.is_active,
|
||||||
|
(SELECT code FROM core_lang WHERE id=core_lang_id) AS lang_code,
|
||||||
|
(SELECT code FROM core_country WHERE id=core_country_id) AS country_code,
|
||||||
|
(SELECT code FROM core_currency WHERE id=core_currency_id) AS currency_code
|
||||||
|
FROM user_user uu
|
||||||
|
INNER JOIN user_detail ud
|
||||||
|
ON uu.id=ud.user_id
|
||||||
|
WHERE uu.email=:email AND uu.password=:password
|
||||||
|
LIMIT 1
|
||||||
|
";
|
||||||
|
|
||||||
|
$execSQL = $oPDOLink->prepare($sql);
|
||||||
|
$execSQL->execute(array(
|
||||||
|
':email'=>$this->_postDatas['formLoginFieldEmail'],
|
||||||
|
':password'=>sha1($this->_postDatas['formLoginFieldPassword'].'-k3P[8x&')
|
||||||
|
));
|
||||||
|
$row = $execSQL->fetch(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
if(isset($row['is_active']) and $row['is_active']==false){
|
||||||
|
echo "if";
|
||||||
|
$message['state'] = 'account_not_activated';
|
||||||
|
$message['css_class'] = 'warning-message';
|
||||||
|
$message['translation_code'] = 'messageLogin_accountNotActivated';
|
||||||
|
return $message;
|
||||||
|
} else if(isset($row['email'])){
|
||||||
|
echo "elif";
|
||||||
|
unset($_SESSION['features']);
|
||||||
|
$_SESSION['features'] = $this->getFeatures($row['id']);
|
||||||
|
echo "features: ";
|
||||||
|
$row['state'] = 'success';
|
||||||
|
return $row;
|
||||||
|
} else{
|
||||||
|
echo "else";
|
||||||
|
$message['state'] = 'bad_login_or_password';
|
||||||
|
$message['css_class'] = 'failed-message';
|
||||||
|
//FIX translate this message
|
||||||
|
$message['translation_code'] = "messageLogin_badLoginOrPassword";
|
||||||
|
return $message;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private function _addFeatureToUser($user_id, $feature_code){
|
private function _addFeatureToUser($user_id, $feature_code){
|
||||||
$this->_userId = $user_id;
|
$this->_userId = $user_id;
|
||||||
$this->_featureCode = $feature_code;
|
$this->_featureCode = $feature_code;
|
||||||
@ -201,89 +285,14 @@ class ClassUser extends ClassConfig {
|
|||||||
}
|
}
|
||||||
//ENDOF activateUser()
|
//ENDOF activateUser()
|
||||||
|
|
||||||
public function login($post_datas=array()){
|
|
||||||
$this->_postDatas = $post_datas;
|
|
||||||
$oPDOLink = ClassConfig::databaseConnect();
|
|
||||||
|
|
||||||
if($this->_postDatas['formLoginFieldEmail']=='' || $this->_postDatas['formLoginFieldPassword']==''){
|
|
||||||
$message['state'] = 'no_required_fields_filled';
|
|
||||||
$message['css_class'] = 'failed-message';
|
|
||||||
$message['translation_code'] = "message_requiredFieldsNotFilled";
|
|
||||||
return $message;
|
|
||||||
}
|
|
||||||
|
|
||||||
$sql="
|
|
||||||
SELECT uu.id, uu.email, uu.password, uu.firstname, uu.lastname, uu.phone,
|
|
||||||
uu.core_lang_id, uu.core_country_id, uu.core_currency_id,
|
|
||||||
uu.is_backend_access, uu.is_employee, uu.is_active,
|
|
||||||
(SELECT code FROM core_lang WHERE id=core_lang_id) AS lang_code,
|
|
||||||
(SELECT code FROM core_country WHERE id=core_country_id) AS country_code,
|
|
||||||
(SELECT code FROM core_currency WHERE id=core_currency_id) AS currency_code
|
|
||||||
FROM user_user uu
|
|
||||||
INNER JOIN user_detail ud
|
|
||||||
ON uu.id=ud.user_id
|
|
||||||
WHERE uu.email=:email AND uu.password=:password
|
|
||||||
LIMIT 1
|
|
||||||
";
|
|
||||||
|
|
||||||
//$sql="
|
|
||||||
//SELECT uu.id, uu.email, uu.password, uu.firstname, uu.lastname, uu.phone,
|
|
||||||
// uu.core_lang_id, uu.core_country_id, uu.core_currency_id,
|
|
||||||
// uu.is_backend_access, uu.is_employee, uu.is_active,
|
|
||||||
// (SELECT code FROM core_lang WHERE id=core_lang_id) AS lang_code,
|
|
||||||
// (SELECT code FROM core_country WHERE id=core_country_id) AS country_code,
|
|
||||||
// (SELECT code FROM core_currency WHERE id=core_currency_id) AS currency_code
|
|
||||||
//FROM user_user uu
|
|
||||||
// INNER JOIN user_detail ud
|
|
||||||
// ON uu.id=ud.user_id
|
|
||||||
//WHERE uu.email=:email AND uu.password=:password
|
|
||||||
//LIMIT 1
|
|
||||||
//";
|
|
||||||
|
|
||||||
$execSQL = $oPDOLink->prepare($sql);
|
|
||||||
$execSQL->execute(array(
|
|
||||||
':email'=>$this->_postDatas['formLoginFieldEmail'],
|
|
||||||
':password'=>sha1($this->_postDatas['formLoginFieldPassword'].'-k3P[8x&')
|
|
||||||
));
|
|
||||||
$row = $execSQL->fetch(PDO::FETCH_ASSOC);
|
|
||||||
if(isset($row['is_active']) and $row['is_active']==false){
|
|
||||||
$message['state'] = 'account_not_activated';
|
|
||||||
$message['css_class'] = 'warning-message';
|
|
||||||
$message['translation_code'] = 'messageLogin_accountNotActivated';
|
|
||||||
return $message;
|
|
||||||
} else if(isset($row['email'])){
|
|
||||||
unset($_SESSION['features']);
|
|
||||||
$_SESSION['features'] = $this->getFeatures($row['id']);
|
|
||||||
$row['state'] = 'success';
|
|
||||||
return $row;
|
|
||||||
} else{
|
|
||||||
$message['state'] = 'bad_login_or_password';
|
|
||||||
$message['css_class'] = 'failed-message';
|
|
||||||
//FIX translate this message
|
|
||||||
$message['translation_code'] = "messageLogin_badLoginOrPassword";
|
|
||||||
return $message;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getFeatures($user_id){
|
|
||||||
$this->_userId = $user_id;
|
|
||||||
$oPDOLink = ClassConfig::databaseConnect();
|
|
||||||
$sql = "
|
|
||||||
SELECT f.*,
|
|
||||||
(SELECT source FROM core_translation WHERE id=f.url_translation_id) AS url,
|
|
||||||
(SELECT source FROM core_translation WHERE id=f.name_translation_id) AS menu_label
|
|
||||||
FROM useruser_corefeature_rel r
|
|
||||||
INNER JOIN core_feature f
|
|
||||||
ON r.core_feature_id=f.id
|
|
||||||
WHERE r.user_id=:user_id
|
|
||||||
AND f.is_active=TRUE
|
|
||||||
ORDER BY f.priority ASC;
|
|
||||||
";
|
|
||||||
$execSQL = $oPDOLink->prepare($sql);
|
|
||||||
$execSQL->execute(array(':user_id'=>$this->_userId));
|
|
||||||
$rows = $execSQL->fetchAll(PDO::FETCH_OBJ);
|
|
||||||
return $rows;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public function setThemeForUser($user_id, $theme_code){
|
public function setThemeForUser($user_id, $theme_code){
|
||||||
@ -850,4 +859,7 @@ class ClassUser extends ClassConfig {
|
|||||||
}
|
}
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
if(isset($_POST['formLoginButtonSubmit'])){
|
if(isset($_POST['formLoginButtonSubmit'])){
|
||||||
$user = new ClassUser();
|
$oUser = new ClassUser();
|
||||||
$user = $oUser->login($_POST);
|
$user = $oUser->login($_POST);
|
||||||
|
|
||||||
if(isset($user['email'])){
|
if(isset($user['email'])){
|
||||||
@ -14,6 +14,7 @@ if(isset($_POST['formLoginButtonSubmit'])){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(isset($_POST['submit_change_password'])){
|
if(isset($_POST['submit_change_password'])){
|
||||||
// Open connection with Globsi Backend
|
// Open connection with Globsi Backend
|
||||||
$userPassword = $oUser->changePassword($_SESSION['user']['id'], $_POST);
|
$userPassword = $oUser->changePassword($_SESSION['user']['id'], $_POST);
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
<?php if(isset($user)) { ?>
|
<?php
|
||||||
|
if(isset($_SESSION['user'])) { ?>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="section">
|
<div class="section">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col s12">
|
<div class="col s12">
|
||||||
<div class="card z-depth-5">
|
<div class="card z-depth-5">
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
<p><?php echo "Welcome ".$user[0]['display_name']; ?></p>
|
<p><?php echo "Welcome ".$_SESSION['user']['email']; ?></p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -19,13 +20,13 @@
|
|||||||
<div class="col s12">
|
<div class="col s12">
|
||||||
<div class="card z-depth-5">
|
<div class="card z-depth-5">
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
<p>Welcome in Wodoo. Create a DB named jmdn_wodoo.<br>
|
<p>"Welcome to the public home page</p>
|
||||||
Execute the file <?php echo $oConf->getURLRoot("__private/install/install-v1.0.0.sql"); ?> in your database.<br>
|
|
||||||
Execute the PHP script <?php echo $oConf->getURLRoot("__private/install/install.php"); ?> to get things done.</p>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user