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,7 +341,12 @@ $("#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) {
|
||||||
|
if (!(new RegExp(/^[a-z\d\-_\s]+$/i).test($(this).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) {
|
||||||
lock_login_fields();
|
lock_login_fields();
|
||||||
var usr = create_unauthenticated_user($(this).val());
|
var usr = create_unauthenticated_user($(this).val());
|
||||||
usr.done(function(data) {
|
usr.done(function(data) {
|
||||||
@ -352,10 +357,13 @@ $("#custom_username_field").keyup(function(event){
|
|||||||
Materialize.toast('Sorry! You are allowed to log in as a guest once every 15 minutes.', 10000);
|
Materialize.toast('Sorry! You are allowed to log in as a guest once every 15 minutes.', 10000);
|
||||||
} else if (data.status == 403) {
|
} else if (data.status == 403) {
|
||||||
Materialize.toast('Authentication error! You have been banned.', 10000);
|
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();
|
unlock_login_fields();
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#messagebox").keyup(function(event){
|
$("#messagebox").keyup(function(event){
|
||||||
|
Loading…
Reference in New Issue
Block a user