440
Views
7
Comments
Solved
Unique Username using Users DB
Question

Hi,


Could someone help me identifying what is the best way to avoid the creation of users with the same username using the system users DB?

I tried to change the index but it seems i cannot since it's kind of greyed out.

Regards,

Joao

2021-10-06 17-41-40
André Rodrigues
Solution

Hi João,

Try something like this in the Submit action of the form, when creating a new User

     

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

Hi Joao,

Who creates the users? And what do you mean by "changing the index"?

Users can't have the same username as another user, unless they have a different user provider. Is that the case?

UserImage.jpg
Joao Siquenique

Kilian Hekhuis wrote:

Hi Joao,

Who creates the users? And what do you mean by "changing the index"?

Users can't have the same username as another user, unless they have a different user provider. Is that the case?

Hi Kilian, 

I am using the outsystems system user DB it came in the template I had for login. 

I've implemented a registration page where I can register new users but the index in the users dB allows not unique usernames and i cannot change that. 

Hope it clarifies. 

Regards, 

Joao 


2021-10-06 17-41-40
André Rodrigues
Solution

Hi João,

Try something like this in the Submit action of the form, when creating a new User

     

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

Hi Joao,

Of course it's not possible to have duplicate usernames, so is your question why that is, or how you can check on duplicates (if the latter, see André's post)?

2021-04-21 23-06-46
Jeanene Williams

If you are doing something like asking the user for their username at registration time then you should use the form validation and check if the user exists and ask the user to enter a different name. See Input Validation for some details on input validation.


2021-04-21 23-06-46
Jeanene Williams

Another option is to encourage users to use a username that would be unique anyway. Email address is a very good one as they have to be unique to start with. Still do the checks above though to trap situations where a user is trying to register twice plus your field validation should check for a valid email. Also good idea to allow a user to edit their username at a later date is some users do change email addresses occasionaly

2019-01-03 21-16-54
Nicolaas Kuit

Hi Kilian,

I was also running into this problem. In our environment, we have multiple developers creating various applications, and each app takes care of creating a user. There's nothing stopping App 1 creating username = "newuser", and App 2 creating username = "newuser". App 1 and App 2 both use the same user provider... specifically the default "Users" user provider. So it IS possible to have duplicate usernames within the same user provider.

Is it by design that the User.Username attribute has no uniqueness constraint? 

I would imagine we don't want the following:

userid = 1, username = "newuser", roles = (App1_RegularUser)

userid = 2, username = "newuser", roles = (App2_Admin)


But instead, we should have:

userid = 1, username = "newuser", roles = (App1_RegularUser, App2_Admin)

Is this the correct thinking? 

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.