Skip to content

Commit ad34a88

Browse files
committed
Added a request to give consent for non-LI information on user login. Addresses issue ietf-tools#2505.
- Legacy-Id: 15211
1 parent eaff1f0 commit ad34a88

3 files changed

Lines changed: 62 additions & 12 deletions

File tree

ietf/ietfauth/views.py

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,11 @@
4646
from django.contrib.auth.forms import AuthenticationForm
4747
from django.contrib.auth.hashers import identify_hasher
4848
from django.contrib.auth.models import User
49-
from django.contrib.auth.views import login as django_login
49+
from django.contrib.auth.views import LoginView
5050
from django.contrib.sites.models import Site
5151
from django.core.validators import ValidationError
5252
from django.urls import reverse as urlreverse
53+
from django.utils.safestring import mark_safe
5354
from django.http import Http404, HttpResponseRedirect #, HttpResponse,
5455
from django.shortcuts import render, redirect, get_object_or_404
5556

@@ -583,6 +584,22 @@ def login(request, extra_context=None):
583584
form = AuthenticationForm(request, data=request.POST)
584585
username = form.data.get('username')
585586
user = User.objects.filter(username=username).first()
587+
#
588+
require_consent = []
589+
if user.person and not user.person.consent:
590+
person = user.person
591+
if person.name != person.name_from_draft:
592+
require_consent.append("full name")
593+
elif person.ascii != person.name_from_draft:
594+
require_consent.append("ascii name")
595+
elif person.biography:
596+
require_consent.append("biography")
597+
elif user.communitylist_set.exists():
598+
require_consent.append("draft notification subscription(s)")
599+
else:
600+
for email in person.email_set.all():
601+
if not email.origin.split(':')[0] in ['author', 'role', 'reviewer', 'liaison', 'shepherd', ]:
602+
require_consent.append("email address(es)")
586603
if user:
587604
try:
588605
identify_hasher(user.password)
@@ -593,8 +610,19 @@ def login(request, extra_context=None):
593610
"Please use the password reset link below "
594611
"to set a new password for your account.",
595612
}
596-
597-
return django_login(request, extra_context=extra_context)
613+
response = LoginView.as_view(extra_context=extra_context)(request)
614+
if isinstance(response, HttpResponseRedirect) and user.is_authenticated():
615+
if require_consent:
616+
messages.warning(request, mark_safe("""
617+
618+
You have personal information associated with your account which is not
619+
derived from draft submissions or other ietf work, namely: %s. Please go
620+
to your <a href='/accounts/profile'>account profile</a> and review your
621+
personal information, and confirm that it may be used and displayed
622+
within the IETF datatracker.
623+
624+
""" % ', '.join(require_consent)))
625+
return response
598626

599627
@login_required
600628
@person_required

ietf/static/ietf/css/ietf.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -658,6 +658,11 @@ ul.list-inline li {
658658
max-width: 85ex;
659659
}
660660

661+
.photo {
662+
max-width: 200px;
663+
}
664+
665+
661666
.bio-photo {
662667
float: left;
663668
margin: 0.3em 1em 0.5em 0.1em;

ietf/templates/registration/edit_profile.html

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,19 @@ <h1>Profile for {{ user.username }}</h1>
7777
</div>
7878
</div>
7979

80+
{% if person.photo %}
81+
<div class="form-group">
82+
<label class="col-sm-2 control-label">Photo &dagger;</label>
83+
<div class="col-sm-10">
84+
<p class="form-control-static">
85+
<a href="{{person.photo.url}}">
86+
<img class="photo" src="{{ person.photo.url }}" alt="Photo of {{ person }}" />
87+
</a>
88+
</p>
89+
</div>
90+
</div>
91+
{% endif %}
92+
8093
<div class="form-group">
8194
<label class="col-sm-2 control-label">Nomcom Eligible</label>
8295
<div class="col-sm-1 form-control-static">{{person|is_nomcom_eligible|yesno:'Yes,No,No'}}</div>
@@ -89,20 +102,24 @@ <h1>Profile for {{ user.username }}</h1>
89102
<label class="col-sm-2 control-label">Email addresses</label>
90103
<div class="col-sm-10">
91104
<div class="row">
92-
<div class="col-sm-5" id="emails">
105+
<div class="col-sm-10" id="emails">
93106
<table class="table table-condensed">
94-
<tr ><th>Primary</th><th>Active</th><th>Address</th></tr>
107+
<tr ><th>Primary</th><th>Active</th><th>Address</th><th>Origin</th></tr>
95108
{% for email in emails %}
96109
<tr >
97110
<td><input type="radio" name="primary_email" value="{{ email.pk }}" {% if email.primary %}checked{% endif %}></td>
98111
<td><input type="checkbox" name="active_emails" value="{{ email.pk }}" {% if email.active %}checked{% endif %}></td>
99-
<td>{{ email }}</td>
112+
<td>
113+
{% if email.origin == person.user.username or email.origin == '' %}&dagger;{% endif %}
114+
{{ email }}
115+
</td>
116+
<td>{{ email.origin|default:'(unknown)' }}</td>
100117
</tr>
101118
{% endfor %}
102119
</table>
103120
</div>
104-
<div class="col-sm-7">
105-
<div class="help-block">Note: Email addresses cannot be deleted, only deactivated.</div>
121+
<div class="col-sm-10">
122+
<div class="help-block">Note: Email addresses cannot be deleted in this form, only deactivated.</div>
106123
</div>
107124
</div>
108125
</div>
@@ -146,11 +163,11 @@ <h1>Profile for {{ user.username }}</h1>
146163
$(document).ready(function() {
147164
$("input[name=active_emails]").on("change keypress click", function () {
148165
if (this.checked) {
149-
$(this).parent().parent().addClass("text-success");;
150-
$(this).parent().parent().removeClass("text-danger line-through");
166+
$(this).parent().next().addClass("text-success");;
167+
$(this).parent().next().removeClass("text-danger line-through");
151168
} else {
152-
$(this).parent().parent().addClass("text-danger line-through");
153-
$(this).parent().parent().removeClass("text-success");
169+
$(this).parent().next().addClass("text-danger line-through");
170+
$(this).parent().next().removeClass("text-success");
154171
}
155172
}).trigger("change");
156173

0 commit comments

Comments
 (0)