Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating a new user should always check if handle already exists - Make handle unique?! #993

Open
q2apro opened this issue Mar 7, 2024 · 2 comments

Comments

@q2apro
Copy link

q2apro commented Mar 7, 2024

I used a plugin that generates userhandles and inserts them. It happened, that users simultaneously signed up and the plugin checked if the userhandle does not exist, which was true for both, then used function qa_db_user_create() to create the new user. Hence, the user handle was assigned twice and even the email was there twice!

Starting questions:

  1. Why in qa_users the column handle is not unique?
  2. Why in qa_users the column email is not unique?

Code question:

  1. Should we change the function qa_db_user_create() so it does something like:
	INSERT INTO `^users` 
	(created, loggedin, createip, email, passhash, level, handle, loginip) 
	SELECT NOW(), NOW(), UNHEX($), $, $, #, $, UNHEX($)
	FROM DUAL 
	WHERE NOT EXISTS (
		SELECT 1 
		FROM `qa_users` 
		WHERE email = $
		OR handle = $
	)

// is "0" IF NO ENTRY WAS CREATED
$userid_new = qa_db_last_insert_id();
  1. Should we make handle and email unique and then catch somehow the error that is casted by MySQL with INSERT INTO.
@q2apro
Copy link
Author

q2apro commented Mar 7, 2024

This is not only a plugin issue. If two users register the same time with question2answer, having the same email or/and the same username, two user accounts would be created.

I have set handle and email to unique:

image

In general, it is irresponsible to allow two userhandles because they can be used for a login - and user A could access the data of user B.

@arjunsuresh
Copy link

I think this makes sense. Thank you for raising this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants