user_name -> username
Change-Id: I2cb601f7e0eeb36a27e9dad662f3554a0092ab18
diff --git a/User.php b/User.php
index fb2bff6..ea144b7 100644
--- a/User.php
+++ b/User.php
@@ -3,7 +3,7 @@
class User
{
- public $user_name;
+ public $username;
public $name;
public $first_name;
public $last_name;
@@ -11,16 +11,34 @@
public $organization;
public $user_hash;
public $password;
+ function __construct()
+ {
+ $this->username = "";
+ $this->name = "";
+ $this->first_name = "";
+ $this->last_name = "";
+ $this->email = "";
+ $this->organization = "";
+ $this->user_hash = "";
+ $this->password = "";
+ }
- function __construct(string $user_name, string $first_name, string $last_name, string $email, string $password, string $organization)
+ function __construct6(string $username, string $first_name, string $last_name, string $email, string $password, string $organization)
{
include 'config.php';
- $this->user_name = $user_name;
+ $this->username = $username;
$this->name = $first_name;
$this->first_name = $first_name;
$this->last_name = $last_name;
$this->email = $email;
$this->organization = $organization;
+ $this->set_password($password);
+
+ }
+
+ function set_password(string $password)
+ {
+ include 'config.php';
if ($ENCRYPT_PASSWORDS) {
$this->user_hash = "{crypt}" . crypt($password, '$6$' . generateSalt(10) . '$');
# $this->user_hash = "{SHA}" . base64_encode(sha1($password, true));
@@ -28,7 +46,6 @@
$this->user_hash = "{CLEAR}" . $password;
}
$this->password = $this->user_hash;
-
}
}
diff --git a/index.php b/index.php
index cfc1785..b019079 100755
--- a/index.php
+++ b/index.php
@@ -130,7 +130,7 @@
$password = $_POST["password"];
$error = "";
- $error .= validate_username($user->user_name);
+ $error .= validate_username($user->username);
$error .= validate_name($user->name, $FIRST_NAME_VALIDATION_ERROR);
$error .= validate_name($user->last_name, $LAST_NAME_VALIDATION_ERROR);
$error .= validate_email($user->email);
@@ -147,7 +147,7 @@
function backup_user_in_session($user)
{
- $_SESSION['username'] = $user->user_name;
+ $_SESSION['username'] = $user->username;
$_SESSION['first_name'] = $user->first_name;
$_SESSION['last_name'] = $user->last_name;
$_SESSION['email'] = $user->email;
diff --git a/ldap.php b/ldap.php
index 637c54f..8f43c23 100755
--- a/ldap.php
+++ b/ldap.php
@@ -53,20 +53,26 @@
include 'config.php';
$ldap_host = $HOST;
$ldap_port = $PORT;
- $base_dn = str_replace('{}', $user->user_name, $BASE_DN);
+ $base_dn = str_replace('{}', $user->username, $BASE_DN);
$ldaptree = explode("{},", $BASE_DN)[1];
$info["givenName"] = $user->first_name;
$info["sn"] = $user->last_name;
- $info["uid"] = $user->user_name;
+ $info["uid"] = $user->username;
#$info["homeDirectory"]="/home/";
$info["mail"] = $user->email;
$info["o"] = $user->organization;
$info["displayName"] = $user->first_name . " " . $user->last_name;
#$info["departmentNumber"]=$user->id;
- $info["cn"] = $user->user_name;
+ $info["cn"] = $user->username;
$info["userPassword"] = $user->user_hash;
+ $info["l"] = $user->city;
+ $info["street"] = $user->street;
+ $info["postalcode"] = $user->zip;
+ $info["l"] = $user->city;
+ $info["co"] = $user->country;
+
$info["objectclass"][0] = "top";
$info["objectclass"][1] = "person";
$info["objectclass"][2] = "inetOrgPerson";
diff --git a/redis.php b/redis.php
index 11333ff..323a74b 100755
--- a/redis.php
+++ b/redis.php
@@ -19,7 +19,10 @@
$redis = connect();
$data = json_decode($redis->get($key));
if ($data && gettype($data) == "object") {
- $user = new User($data->user_name, $data->first_name, $data->last_name, $data->email, $data->password, $data->organization);
+ $user = new User();
+ foreach ($data as $key => $value) $user->{$key} = $value;
+ if (isset($data->password)) $user->set_password($data->password);
+ #$user = new User($data->username, $data->first_name, $data->last_name, $data->email, $data->password, $data->organization);
return $user;
} else {
return null;
diff --git a/utils.php b/utils.php
index 44160c0..41996fb 100644
--- a/utils.php
+++ b/utils.php
@@ -67,11 +67,11 @@
$string = str_replace("{{last_name}}", $user->last_name, $string);
$string = str_replace("{{email}}", $user->email, $string);
$string = str_replace("{{organization}}", $user->organization, $string);
- $string = str_replace("{{username}}", $user->user_name, $string);
+ $string = str_replace("{{username}}", $user->username, $string);
return $string;
}
function user_to_string(User $user)
{
- return $user->first_name . " " . $user->last_name . " <" . $user->email . "> " . $user->organization . " " . $user->user_name;
+ return $user->first_name . " " . $user->last_name . " <" . $user->email . "> " . $user->organization . " " . $user->username;
}
\ No newline at end of file