mirror of
https://github.com/TitanEmbeds/Titan.git
synced 2024-12-25 06:27:03 +01:00
Check illegal username
This commit is contained in:
parent
9801aafb58
commit
0509b44078
@ -274,8 +274,11 @@ def create_unauthenticated_user():
|
|||||||
username = request.form['username']
|
username = request.form['username']
|
||||||
guild_id = request.form['guild_id']
|
guild_id = request.form['guild_id']
|
||||||
ip_address = get_client_ipaddr()
|
ip_address = get_client_ipaddr()
|
||||||
|
username = username.strip()
|
||||||
if len(username) < 2 or len(username) > 32:
|
if len(username) < 2 or len(username) > 32:
|
||||||
abort(406)
|
abort(406)
|
||||||
|
if not all(x.isalpha() or x.isspace() or "-" == x or "_" == x for x in username):
|
||||||
|
abort(406)
|
||||||
if not check_guild_existance(guild_id):
|
if not check_guild_existance(guild_id):
|
||||||
abort(404)
|
abort(404)
|
||||||
if not guild_query_unauth_users_bool(guild_id):
|
if not guild_query_unauth_users_bool(guild_id):
|
||||||
|
@ -341,20 +341,28 @@ $("#discordlogin_btn").click(function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
$("#custom_username_field").keyup(function(event){
|
$("#custom_username_field").keyup(function(event){
|
||||||
if(event.keyCode == 13 && $(this).val().length >= 2 && $(this).val().length <= 32) {
|
if (event.keyCode == 13) {
|
||||||
lock_login_fields();
|
if (!(new RegExp(/^[a-z\d\-_\s]+$/i).test($(this).val()))) {
|
||||||
var usr = create_unauthenticated_user($(this).val());
|
Materialize.toast('Illegal username provided! Only alphanumeric, spaces, dashes, and underscores allowed in usernames.', 10000);
|
||||||
usr.done(function(data) {
|
return;
|
||||||
initialize_embed();
|
}
|
||||||
});
|
if($(this).val().length >= 2 && $(this).val().length <= 32) {
|
||||||
usr.fail(function(data) {
|
lock_login_fields();
|
||||||
if (data.status == 429) {
|
var usr = create_unauthenticated_user($(this).val());
|
||||||
Materialize.toast('Sorry! You are allowed to log in as a guest once every 15 minutes.', 10000);
|
usr.done(function(data) {
|
||||||
} else if (data.status == 403) {
|
initialize_embed();
|
||||||
Materialize.toast('Authentication error! You have been banned.', 10000);
|
});
|
||||||
}
|
usr.fail(function(data) {
|
||||||
unlock_login_fields();
|
if (data.status == 429) {
|
||||||
})
|
Materialize.toast('Sorry! You are allowed to log in as a guest once every 15 minutes.', 10000);
|
||||||
|
} else if (data.status == 403) {
|
||||||
|
Materialize.toast('Authentication error! You have been banned.', 10000);
|
||||||
|
} else if (data.status == 406) {
|
||||||
|
Materialize.toast('Illegal username provided! Only alphanumeric, spaces, dashes, and underscores allowed in usernames.', 10000);
|
||||||
|
}
|
||||||
|
unlock_login_fields();
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user