diff --git a/core/views/user_registration.py b/core/views/user_registration.py index 902a02da2..972d82b61 100644 --- a/core/views/user_registration.py +++ b/core/views/user_registration.py @@ -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() diff --git a/templates/login/register.html b/templates/login/register.html index 067089436..539306eef 100644 --- a/templates/login/register.html +++ b/templates/login/register.html @@ -52,7 +52,10 @@ You are not logged in as the user you are attempting to re-register.
This will eventually sign you up automatically to the expo email list. So type in the same email address that you use there. - +
+ +{{ warning }} +