2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2026-03-23 00:12:19 +00:00

ensure anonymous before changing registration

This commit is contained in:
2025-01-21 19:17:51 +00:00
parent d19b1e79ab
commit a784ca8641
3 changed files with 22 additions and 7 deletions

View File

@@ -28,7 +28,7 @@ def register(request, username=None):
"""To register a new user on the troggle system, similar to the "expo" user
(with cavey:beery password) but specific to an individual
"""
current_user = request.user
current_user = request.user # if not logged in, this is 'AnonymousUser'
if request.method == "POST":
form = register_form(request.POST)
@@ -49,14 +49,20 @@ def register(request, username=None):
# to do, login automatically, and redirect to control panel ?
return HttpResponseRedirect("/accounts/login/")
else:
if current_user:
if username:
if current_user.is_anonymous:
warning = ""
else:
warning = f"WARNING - you are logged-in as someone else '{current_user}'. You must logout and login again as '{username}' "
print(f"REGISTER: {warning}")
form = register_form(initial={"visible": "True", "username": username} )
elif current_user:
form = register_form(initial={"visible": "True", "username": current_user.username})
elif username:
form = register_form(initial={"visible": "True", "username": username})
else:
form = register_form(initial={"visible": "True"})
return render(request, "login/register.html", {"form": form})
return render(request, "login/register.html", {"form": form, "warning": warning})
def save_users(request, updated_user, email):
f = get_encryptor()

View File

@@ -52,7 +52,10 @@ You are not logged in as the user you are attempting to re-register.
<p>This will eventually sign you up automatically to the
<a href="https://lists.wookware.org/cgi-bin/mailman/roster/expo">expo email list</a>.
So type in the same email address that you use there.
<p>
<span style="color:red">
{{ warning }}
</span>
<div style='width: 700px; font-family: monospace; font-weight: bold; font-size: 150%; text-align: right; '>
<form method="post" accept-charset="utf-8">{% csrf_token %}

View File

@@ -37,7 +37,13 @@
</table>
<h3>Surveys done</h3>
Wallets and surveys mentioning <a href="/wallets/person/{{person}}">{{person.fullname|safe}}</a><br>
{% if person.user %}
This person has a 'troggle user' logon '{{person.user}}' and a registered email address. <br />
<a href="/accounts/register/{{person.slug}}">RE-REGISTER</a> but only after logging-on as '{{person.user}}'
{% else %}
<a href="/accounts/register/{{person.slug}}">REGISTER</a> as a troggle user
{% endif %}
<br />
{% if person.blurb %}
{{person.blurb|safe}}
{% else %}