forked from cory/tildefriends
		
	auth: Provide some feedback about valid account names. #92
This commit is contained in:
		@@ -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)
 | 
								if (form_register && strcmp(form_register, "1") == 0)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				bool registered = false;
 | 
									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);
 | 
										login_error = "Invalid username.  Usernames must contain only letters from the English alphabet and digits and must start with a letter.";
 | 
				
			||||||
					registered = tf_ssb_db_register_account(tf_ssb_get_loop(ssb), db, context, account_name, password);
 | 
									}
 | 
				
			||||||
					tf_ssb_release_db_writer(ssb, db);
 | 
									else
 | 
				
			||||||
					if (registered)
 | 
									{
 | 
				
			||||||
 | 
										if (!have_account && _is_name_valid(account_name) && password && confirm && strcmp(password, confirm) == 0)
 | 
				
			||||||
					{
 | 
										{
 | 
				
			||||||
						tf_free((void*)send_session);
 | 
											sqlite3* db = tf_ssb_acquire_db_writer(ssb);
 | 
				
			||||||
						send_session = _make_session_jwt(context, ssb, account_name);
 | 
											registered = tf_ssb_db_register_account(tf_ssb_get_loop(ssb), db, context, account_name, password);
 | 
				
			||||||
						may_become_first_admin = true;
 | 
											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.";
 | 
										login_error = "Error registering account.";
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user