function validate_user(&$user) { if (isset($_POST['submit_registration']) && validate_registration($user)) { return true; // Successful registration } else { if (isset($_POST['submit_login']) && validate_login($user)) { return true; // Successful login } else { if ($user->id > 0) { return true; // Already logged in } else { return false; // Request credentials } } } }
function registration_model_helper($bid, $pin) { // Make sure that the passport has not already been registered. If it has // already been registered, then we can go straight to the stats. If not, // we try to submit the user's registration. if (is_registered($bid)) { return handle_stats($bid, $pin); } else { $registration = sanitized_registration(); // Make sure that the entered registration fields are valid. $badRegistrationFields = validate_registration($registration); if (count($badRegistrationFields) == 0) { register_user($bid, $registration); $user = get_user($bid); log_entry(LOG_MODE_USER, LOG_USER_ACTION_REGISTER, array("actorUid" => $user["uid"], "actorBid" => $bid, "targetUid" => $user["uid"], "targetBid" => $bid, "comment" => addslashes(serialize($registration)))); return handle_stats($bid, $pin, array("justRegistered" => true)); } else { return handle_registration($bid, $pin, $registration, array("badRegistration" => $badRegistrationFields)); } } }