auth: Provide some feedback about valid account names. #92
All checks were successful
Build Tilde Friends / Build-All (push) Successful in 23m8s
All checks were successful
Build Tilde Friends / Build-All (push) Successful in 23m8s
This commit is contained in:
parent
42da5d8d32
commit
d202f4e00d
@ -2080,19 +2080,26 @@ static void _httpd_endpoint_login_work(tf_ssb_t* ssb, void* user_data)
|
||||
if (form_register && strcmp(form_register, "1") == 0)
|
||||
{
|
||||
bool registered = false;
|
||||
if (!have_account && _is_name_valid(account_name) && password && confirm && strcmp(password, confirm) == 0)
|
||||
if (!_is_name_valid(account_name))
|
||||
{
|
||||
sqlite3* db = tf_ssb_acquire_db_writer(ssb);
|
||||
registered = tf_ssb_db_register_account(tf_ssb_get_loop(ssb), db, context, account_name, password);
|
||||
tf_ssb_release_db_writer(ssb, db);
|
||||
if (registered)
|
||||
login_error = "Invalid username. Usernames must contain only letters from the English alphabet and digits and must start with a letter.";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!have_account && _is_name_valid(account_name) && password && confirm && strcmp(password, confirm) == 0)
|
||||
{
|
||||
tf_free((void*)send_session);
|
||||
send_session = _make_session_jwt(context, ssb, account_name);
|
||||
may_become_first_admin = true;
|
||||
sqlite3* db = tf_ssb_acquire_db_writer(ssb);
|
||||
registered = tf_ssb_db_register_account(tf_ssb_get_loop(ssb), db, context, account_name, password);
|
||||
tf_ssb_release_db_writer(ssb, db);
|
||||
if (registered)
|
||||
{
|
||||
tf_free((void*)send_session);
|
||||
send_session = _make_session_jwt(context, ssb, account_name);
|
||||
may_become_first_admin = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!registered)
|
||||
if (!registered && !login_error)
|
||||
{
|
||||
login_error = "Error registering account.";
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user