From 9e53f16eb20527a1246171881acd337f9c887d5b Mon Sep 17 00:00:00 2001 From: Jeremy Zhang Date: Fri, 16 Feb 2018 01:12:25 +0000 Subject: [PATCH] Auto logs user in with prefilled guest username if no captcha is present --- webapp/titanembeds/constants.py | 2 +- webapp/titanembeds/static/js/embed.js | 2 ++ webapp/titanembeds/templates/embed.html.j2 | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/webapp/titanembeds/constants.py b/webapp/titanembeds/constants.py index f386359..71151db 100644 --- a/webapp/titanembeds/constants.py +++ b/webapp/titanembeds/constants.py @@ -73,7 +73,7 @@ QUERY_PARAMETERS = [ { "name": "username", "type": "string", - "description": "Prefills the guest username field with the given username.", + "description": "Prefills the guest username field with the given username. If the guest captcha is disabled and that the user has not been logged in yet, it automatically logs the user in with the specified username.", "example": "Rainbow%20Dash", }, { diff --git a/webapp/titanembeds/static/js/embed.js b/webapp/titanembeds/static/js/embed.js index bf32d6d..2ca342f 100644 --- a/webapp/titanembeds/static/js/embed.js +++ b/webapp/titanembeds/static/js/embed.js @@ -415,6 +415,8 @@ unlock_login_fields(); if (data.status == 403 && getParameterByName("create_authenticated_user") == "true" && getParameterByName("sametarget") == "true") { wait_for_discord_login(); + } else if (!unauth_captcha_enabled && $("#custom_username_field").val().trim() !== "") { + $("#custom_username_field").trigger(jQuery.Event("keyup", { keyCode: 13 } )); } else if (visitors_enabled) { setVisitorMode(true); var guild2 = query_guild(); diff --git a/webapp/titanembeds/templates/embed.html.j2 b/webapp/titanembeds/templates/embed.html.j2 index 08dfafc..89ec6b8 100644 --- a/webapp/titanembeds/templates/embed.html.j2 +++ b/webapp/titanembeds/templates/embed.html.j2 @@ -411,7 +411,7 @@ const guild_id = "{{ guild_id }}"; const bot_client_id = "{{ client_id }}"; const visitors_enabled = {% if visitors_enabled %}true{% else %}false{% endif %}; - const unauth_captcha_enabled = {% if unauth_captcha_enabled %}true{% else %}false{% endif %} + const unauth_captcha_enabled = {% if unauth_captcha_enabled %}true{% else %}false{% endif %};