Skip to content

Commit

Permalink
Christmas jingles (#55)
Browse files Browse the repository at this point in the history
* Add account requests, email user on password update, RFC2307BIS autodetection and various bug fixes.

* Remove test.php
  • Loading branch information
wheelybird committed Dec 24, 2020
1 parent ff17c6e commit 3b8e94c
Show file tree
Hide file tree
Showing 23 changed files with 800 additions and 226 deletions.
19 changes: 16 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
FROM php:7.0-apache

RUN apt-get update && apt-get install -y --no-install-recommends libldb-dev libldap2-dev && rm -rf /var/lib/apt/lists/* && ln -s /usr/lib/x86_64-linux-gnu/libldap.so /usr/lib/libldap.so \
&& ln -s /usr/lib/x86_64-linux-gnu/liblber.so /usr/lib/liblber.so
RUN docker-php-source extract && docker-php-ext-install -j$(nproc) ldap && docker-php-source delete
RUN apt-get update && \
apt-get install -y --no-install-recommends \
libldb-dev libldap2-dev \
libfreetype6-dev \
libjpeg-dev \
libpng-dev && \
rm -rf /var/lib/apt/lists/* && \
ln -s /usr/lib/x86_64-linux-gnu/libldap.so /usr/lib/libldap.so && \
ln -s /usr/lib/x86_64-linux-gnu/liblber.so /usr/lib/liblber.so

RUN docker-php-ext-configure gd \
--enable-gd-native-ttf \
--with-freetype-dir=/usr/include/freetype2 \
--with-png-dir=/usr/include \
--with-jpeg-dir=/usr/include && \
docker-php-ext-install -j$(nproc) ldap gd

ADD https://github.com/PHPMailer/PHPMailer/archive/v6.2.0.tar.gz /tmp

Expand Down
137 changes: 70 additions & 67 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion entrypoint
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ EoCertConf
########################
#Create Apache config
if [ -f "/opt/tls/chain.pem" ]; then ssl_chain="SSLCertificateChainFile /opt/tls/chain.pem"; fi
if [ -f "${ssl_dir}/chain.pem" ]; then ssl_chain="SSLCertificateChainFile ${ssl_dir}/chain.pem"; fi
cat <<EoHTTPSC >/etc/apache2/sites-enabled/lum.conf
Expand Down
9 changes: 7 additions & 2 deletions www/account_manager/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,8 @@
}

}

#'
$people = ldap_get_user_list($ldap_connection);
ldap_close($ldap_connection);

?>
<div class="container">
Expand All @@ -64,15 +63,20 @@
<th>First name</th>
<th>Last name</th>
<th>Email</th>
<th>Member of</th>
</tr>
</thead>
<tbody>
<?php
foreach ($people as $username => $attribs){

$group_membership = ldap_user_group_membership($ldap_connection,$username);

print " <tr>\n <td><a href='/$THIS_MODULE_PATH/show_user.php?username=" . urlencode($username) . "'>$username</a></td>\n";
print " <td>" . $people[$username]['givenname'] . "</td>\n";
print " <td>" . $people[$username]['sn'] . "</td>\n";
print " <td>" . $people[$username]['mail'] . "</td>\n";
print " <td>" . implode(", ", $group_membership) . "</td>\n";
print " </tr>\n";
}
?>
Expand All @@ -81,5 +85,6 @@
</div>
<?php

ldap_close($ldap_connection);
render_footer();
?>
2 changes: 1 addition & 1 deletion www/account_manager/module_functions.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function render_submenu() {
print '<li>';
}
print "<a href='/${THIS_MODULE_PATH}/{$path}'>" . ucwords($submodule) . "</a></li>\n";

}
?>
</ul>
Expand Down
34 changes: 25 additions & 9 deletions www/account_manager/new_user.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,26 @@
$invalid_username = FALSE;
$weak_password = FALSE;
$invalid_email = FALSE;
$disabled_email_tickbox = TRUE;

if ($SMTP['host'] != "") { $can_send_email = TRUE; } else { $can_send_email = FALSE; }
if (isset($_GET['account_request'])) {

$first_name=filter_var($_GET['first_name'], FILTER_SANITIZE_STRING);
$last_name=filter_var($_GET['last_name'], FILTER_SANITIZE_STRING);
$email=filter_var($_GET['email'], FILTER_SANITIZE_EMAIL);
$username = generate_username($first_name,$last_name);

if ($email == "") {
if (isset($EMAIL_DOMAIN)) {
$email = $username . "@" . $EMAIL_DOMAIN;
$disabled_email_tickbox = FALSE;
}
}
else {
$disabled_email_tickbox = FALSE;
}

}

if (isset($_POST['create_account'])) {

Expand All @@ -53,7 +70,7 @@
if (preg_match("/\"|'/",$password)) { $invalid_password = TRUE; }
if ($_POST['password'] != $_POST['password_match']) { $mismatched_passwords = TRUE; }
if (!preg_match("/$USERNAME_REGEX/",$username)) { $invalid_username = TRUE; }
if (isset($_POST['send_email']) and isset($email) and $can_send_email == TRUE) { $send_user_email = TRUE; }
if (isset($_POST['send_email']) and isset($email) and $EMAIL_SENDING_ENABLED == TRUE) { $send_user_email = TRUE; }


if ( isset($first_name)
Expand Down Expand Up @@ -84,8 +101,7 @@
Username: $username
Password: $password
You should change your password as soon as possible. Log into the account manager at ${SITE_PROTOCOL}${SERVER_HOSTNAME}/log_in using your credentials.
Once logged in you can change your password at ${SITE_PROTOCOL}${SERVER_HOSTNAME}/change_password/
You should change your password as soon as possible. Go to ${SITE_PROTOCOL}${SERVER_HOSTNAME}/change_password and log in using your new credentials. This will take you to a page where you can change your password.
EoT;

include_once "mail_functions.inc.php";
Expand Down Expand Up @@ -216,15 +232,15 @@ function back_to_hidden(passwordField,confirmField) {

function check_email_validity(email) {

var check_regex = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
var check_regex = <?php print $JS_EMAIL_REGEX; ?>

if (! check_regex.test(email) ) {
document.getElementById("email_div").classList.add("has-error");
<?php if ($can_send_email == TRUE) { ?>document.getElementById("send_email_checkbox").disabled = true;<?php } ?>
<?php if ($EMAIL_SENDING_ENABLED == TRUE) { ?>document.getElementById("send_email_checkbox").disabled = true;<?php } ?>
}
else {
document.getElementById("email_div").classList.remove("has-error");
<?php if ($can_send_email == TRUE) { ?>document.getElementById("send_email_checkbox").disabled = false;<?php } ?>
<?php if ($EMAIL_SENDING_ENABLED == TRUE) { ?>document.getElementById("send_email_checkbox").disabled = false;<?php } ?>
}

}
Expand Down Expand Up @@ -289,11 +305,11 @@ function check_email_validity(email) {
</div>
</div>

<?php if ($can_send_email == TRUE and $admin_setup != TRUE) { ?>
<?php if ($EMAIL_SENDING_ENABLED == TRUE and $admin_setup != TRUE) { ?>
<div class="form-group" id="send_email_div">
<label for="send_email" class="col-sm-3 control-label"> </label>
<div class="col-sm-6">
<input tabindex="8" type="checkbox" class="form-check-input" id="send_email_checkbox" name="send_email" disabled> Email these credentials to the user?
<input tabindex="8" type="checkbox" class="form-check-input" id="send_email_checkbox" name="send_email" <?php if ($disabled_email_tickbox == TRUE) { print "disabled"; } ?>> Email these credentials to the user?
</div>
</div>
<?php } ?>
Expand Down
30 changes: 15 additions & 15 deletions www/account_manager/show_group.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@

$non_members = array_diff($all_people,$updated_membership);
$group_members = $updated_membership;

?>
<script>
window.setTimeout(function() {
Expand All @@ -90,9 +90,9 @@
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="TRUE">&times;</span></button>
<strong>Success!</strong> The group has been updated.
</div>

<?php

}
else {
$group_members = $current_members;
Expand All @@ -108,16 +108,16 @@ function show_delete_group_button() {

var group_del_submit = document.getElementById('delete_group');
group_del_submit.classList.replace('invisible','visible');


}


function update_form_with_users() {

var members_form = document.getElementById('group_members');
var member_list_ul = document.getElementById('membership_list');

var member_list = member_list_ul.getElementsByTagName("li");

for (var i = 0; i < member_list.length; ++i) {
Expand All @@ -126,11 +126,11 @@ function update_form_with_users() {
hidden.name = i;
hidden.value = member_list[i]['textContent'];
members_form.appendChild(hidden);

}

members_form.submit();

}

$(function () {
Expand Down Expand Up @@ -194,9 +194,9 @@ function update_form_with_users() {
.list-arrows button {
margin-bottom: 20px;
}
.right_button {
width: 200px;

.right_button {
width: 200px;
float: right;
}
</style>
Expand All @@ -217,7 +217,7 @@ function update_form_with_users() {
<div class="panel-body">

<div class="row">

<div class="dual-list list-left col-md-5">
<strong>Members</strong>
<div class="well">
Expand Down
Loading

0 comments on commit 3b8e94c

Please sign in to comment.