Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions mig/shared/accountreq.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
Expand All @@ -20,7 +20,7 @@
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Check warning on line 23 in mig/shared/accountreq.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (81 > 80 characters)
#
# -- END_HEADER ---
#
Expand All @@ -46,14 +46,14 @@
from mig.shared.base import auth_type_description, canonical_user, \
client_id_dir, distinguished_name_to_user, fill_distinguished_name, \
fill_user, force_utf8, force_native_str_rec, get_user_id, mask_creds
from mig.shared.defaults import peers_fields, peers_filename, \

Check failure on line 49 in mig/shared/accountreq.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused import 'peers_filename' (90% confidence)
pending_peers_filename, keyword_auto, user_db_filename, \
gdp_distinguished_field
from mig.shared.fileio import delete_file, make_temp_file
from mig.shared.notification import notify_user
from mig.shared.pwcrypto import check_hash, check_scramble
# Expose some helper variables for functionality backends
from mig.shared.safeinput import name_extras, password_extras, \

Check failure on line 56 in mig/shared/accountreq.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused import 'valid_password_chars' (90% confidence)

Check failure on line 56 in mig/shared/accountreq.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused import 'valid_name_chars' (90% confidence)

Check failure on line 56 in mig/shared/accountreq.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused import 'password_extras' (90% confidence)

Check failure on line 56 in mig/shared/accountreq.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused import 'name_extras' (90% confidence)

Check failure on line 56 in mig/shared/accountreq.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused import 'dn_max_len' (90% confidence)
password_min_len, password_max_len, valid_password_chars, \
valid_name_chars, dn_max_len, html_escape, validated_input, REJECT_UNSET
from mig.shared.serial import load, dump, dumps
Expand All @@ -63,29 +63,29 @@
from mig.shared.validstring import valid_email_addresses


def account_css_helpers(configuration):

Check failure on line 66 in mig/shared/accountreq.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused function 'account_css_helpers' (60% confidence)
"""CSS to include in the cert/oid account req page header"""
css = '''
<link rel="stylesheet" type="text/css" href="/images/css/jquery.accountform.css" media="screen"/>

Check warning on line 69 in mig/shared/accountreq.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (97 > 80 characters)
'''
return css


def account_js_helpers(configuration, fields):

Check failure on line 74 in mig/shared/accountreq.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused function 'account_js_helpers' (60% confidence)
"""Javascript to include in the cert/oid account req page header"""
# TODO: change remaining names and messages to fit generic auth account?
add_import = '''
<script type="text/javascript" src="/images/js/jquery.form.js"></script>
<script type="text/javascript" src="/images/js/jquery.accountform.js"></script>
'''
add_init = """
add_init = r"""
/* Helper to define countries for which State field makes sense */
var enable_state = ['US', 'CA', 'AU'];
var peers_mandatory = %(peers_mandatory)s;
var peers_explicit_fields = %(peers_explicit_fields)s;

function rtfm_warn(message) {
return confirm(message + ': Proceed anyway? (If you read and followed the instructions!)');

Check warning on line 88 in mig/shared/accountreq.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (97 > 80 characters)
}
function rtfm_error(message) {
alert(message + ': Please read and follow the instructions!');
Expand Down Expand Up @@ -120,7 +120,7 @@
}
}
function deprecated_email(value) {
if (value.search('@gmail.com') != -1 || value.search('@yahoo.com') != -1 || value.search('@hotmail.com') != -1) {

Check warning on line 123 in mig/shared/accountreq.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (119 > 80 characters)
return true;
} else {
return false;
Expand Down Expand Up @@ -167,7 +167,7 @@
}
function check_organization() {
//alert('#organization_help');
if ($('#email_field').val().search('.ku.dk') != -1 || $('#email_field').val().search('diku.dk') != -1 || $('#email_field').val().search('nbi.dk') != -1) {

Check warning on line 170 in mig/shared/accountreq.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (160 > 80 characters)
if ($('#organization_field').val().indexOf(' ') != -1) {
return rtfm_warn('Organization does not look like an acronym');
}
Expand All @@ -185,7 +185,7 @@
//alert('#state_help');
if (enable_state.indexOf($('#country_field').val()) == -1) {
if ($('#state_field').val() && $('#state_field').val() != 'NA') {
return rtfm_warn('State only makes sense for '+enable_state.join(', ')+' users');

Check warning on line 188 in mig/shared/accountreq.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (95 > 80 characters)
}
}
return true;
Expand All @@ -203,9 +203,9 @@
//alert('#verifypassword_help');
if ($('#verifypassword_field').val().length < %(password_min_len)d) {
return rtfm_warn('Verify password too short');
} else if ($('#verifypassword_field').val().length > %(password_max_len)d) {

Check warning on line 206 in mig/shared/accountreq.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (82 > 80 characters)
return rtfm_warn('Verify password too long');
} else if ($('#password_field').val() != $('#verifypassword_field').val()) {

Check warning on line 208 in mig/shared/accountreq.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (82 > 80 characters)
return rtfm_warn('Mismatch between password and verify password');
}
return true;
Expand All @@ -217,7 +217,7 @@
}
var base_err = 'One or more peers contact full names must be provided';
/* NOTE: split on comma and verbatim 'and' with space removal */
var all_parts = $('#peers_full_name_field').val().trim().split(/\s*,\s*|\s+and\s+/);

Check warning on line 220 in mig/shared/accountreq.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (90 > 80 characters)
if (all_parts.length < 1) {
rtfm_error(base_err);
return false;
Expand All @@ -239,7 +239,7 @@
}
var base_err = 'One or more peers contact emails must be provided';
/* NOTE: split on comma and verbatim 'and' with space removal */
var all_parts = $('#peers_email_field').val().trim().split(/\s*,\s*|\s+and\s+/);

Check warning on line 242 in mig/shared/accountreq.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (86 > 80 characters)
if (all_parts.length < 1) {
rtfm_error(base_err);
return false;
Expand Down Expand Up @@ -371,7 +371,7 @@
return (add_import, add_init, add_ready)


def account_request_template(configuration, password=True, default_values={}):

Check failure on line 374 in mig/shared/accountreq.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused function 'account_request_template' (60% confidence)
"""A general form template used for various account requests"""

# Require user to explicitly accept terms of use unless overriden
Expand Down Expand Up @@ -527,7 +527,7 @@
comment_pattern = ''

if 'full_name' in configuration.site_peers_explicit_fields:
html += """
html += r"""
<div class='form-row single-entry %(show_peers_full_name)s'>
<div class='col-md-12 mb-3 form-cell'>
<!-- NOTE: this simple form control just looks for one or more full names.
Expand All @@ -544,7 +544,7 @@
</div>
"""
if 'email' in configuration.site_peers_explicit_fields:
html += """
html += r"""
<div class='form-row single-entry %(show_peers_email)s'>
<div class='col-md-12 mb-3 form-cell'>
<!-- NOTE: this simple form control just looks for one or more emails.
Expand Down