Add adress and phone number attributes
Change-Id: I7e69468ac6e5a05f42120a42bf02b92f18773ca7
diff --git a/index.php b/index.php
index b019079..d2ae3a1 100755
--- a/index.php
+++ b/index.php
@@ -131,7 +131,7 @@
$error = "";
$error .= validate_username($user->username);
- $error .= validate_name($user->name, $FIRST_NAME_VALIDATION_ERROR);
+ $error .= validate_name($user->first_name, $FIRST_NAME_VALIDATION_ERROR);
$error .= validate_name($user->last_name, $LAST_NAME_VALIDATION_ERROR);
$error .= validate_email($user->email);
$error .= validate_password($password);
@@ -145,14 +145,6 @@
return $error;
}
-function backup_user_in_session($user)
-{
- $_SESSION['username'] = $user->username;
- $_SESSION['first_name'] = $user->first_name;
- $_SESSION['last_name'] = $user->last_name;
- $_SESSION['email'] = $user->email;
- $_SESSION['organization'] = $user->organization;
-}
function approve_request(User $user)
{
@@ -177,10 +169,10 @@
send_confirmation_email($user->email, $smtp, $url, $user);
$_SESSION['resend'] = generateRandomString(12);
$_SESSION['token'] = $token;
- backup_user_in_session($user);
+ $user->backup_in_session();
$TEMPLATE = template_path();
include $TEMPLATE . "confirm_your_email.htm";
- $log->info("Registration process started for " . user_to_string($user));
+ $log->info("Registration process started for " . $user->to_string());
}
function recover_form($error = null)
@@ -210,7 +202,10 @@
if (isset($_POST['type'])) {
switch ($_POST['type']) {
case "register":
- $user = new User($_POST["username"], $_POST["name"], $_POST["last_name"], $_POST["email"], $_POST["password"], $_POST["organization"]);
+ $log->info("Registration request from " . array_to_string($_POST));
+ $user = new User();
+ $user->init_from_array($_POST);
+ $log->info("Registration request from " . $user->to_string());
if (redis_inc_ipdata(getClientIP(), "register", true) > $HOURLY_REGISTRATIONS) {
include $TEMPLATE . "registration_limit.htm";
} else {
@@ -313,12 +308,12 @@
}
}
redis_inc_ipdata(getClientIP(), "register");
- $log->info("User registered: " . user_to_string($user));
+ $log->info("User registered: " . $user->to_string());
echo $STRINGS->email_confirmation;
if (isset($POST_REGISTER_HOOK)) $POST_REGISTER_HOOK($user);
include $TEMPLATE . "mail_confirmed.htm";
} else {
- $log->error("User registration failed for: " . user_to_string($user));
+ $log->error("User registration failed for: " . $user->to_string());
echo $STRINGS->email_confirmation;
include $TEMPLATE . "registration_error.htm";
}