mirror of
				https://github.com/TitanEmbeds/Titan.git
				synced 2025-11-04 07:47:10 +01:00 
			
		
		
		
	Implement a guest login button, initially hidden
This commit is contained in:
		@@ -446,6 +446,10 @@ a {
 | 
			
		||||
  max-width: 100%;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#guestlogin_btn {
 | 
			
		||||
  display: none;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#modal_invite_btn {
 | 
			
		||||
  padding: 0 1em;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1489,11 +1489,20 @@
 | 
			
		||||
    
 | 
			
		||||
    $("#custom_username_field").keyup(function(event){
 | 
			
		||||
        if (event.keyCode == 13) {
 | 
			
		||||
            if (!(new RegExp(/^[a-z\d\-_\s]+$/i).test($(this).val()))) {
 | 
			
		||||
            do_guest_login();
 | 
			
		||||
        }
 | 
			
		||||
    });
 | 
			
		||||
    
 | 
			
		||||
    $("#guestlogin_btn").click(function () {
 | 
			
		||||
        do_guest_login();
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    function do_guest_login() {
 | 
			
		||||
        if (!(new RegExp(/^[a-z\d\-_\s]+$/i).test($("#custom_username_field").val()))) {
 | 
			
		||||
            Materialize.toast('Illegal username provided! Only alphanumeric, spaces, dashes, and underscores allowed in usernames.', 10000);
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
            if($(this).val().length >= 2 && $(this).val().length <= 32) {
 | 
			
		||||
        if($("#custom_username_field").val().length >= 2 && $("#custom_username_field").val().length <= 32) {
 | 
			
		||||
            $("#custom_username_field").blur();
 | 
			
		||||
            if (unauth_captcha_enabled) {
 | 
			
		||||
                $('#recaptchamodal').modal('open');
 | 
			
		||||
@@ -1502,7 +1511,6 @@
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    $("#submit-unauthenticated-captcha-btn").click(function(){
 | 
			
		||||
        lock_login_fields();
 | 
			
		||||
 
 | 
			
		||||
@@ -149,6 +149,7 @@
 | 
			
		||||
                  <p id="guest_login_instr">{{ _("Of course, you also have the option to login by picking a temporary username for your current browsing session.") }}</p>
 | 
			
		||||
                  <input id="custom_username_field" type="text" {% if session.unauthenticated and session.username %}value="{{ session['username'] }}"{% endif %}>
 | 
			
		||||
                  <label id="custom_username_field_label" class="active" for="custom_username_field">{{ _("Username (Hit ENTER/RETURN key to confirm)") }}</label>
 | 
			
		||||
                  <a id="guestlogin_btn" class="waves-effect waves-light btn-large">Guest Login</a>
 | 
			
		||||
                </div>
 | 
			
		||||
                {% endif %}
 | 
			
		||||
              </div>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user