mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2026-04-02 11:31:03 +01:00
ensure anonymous before changing registration
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user