Hello,

I created my own registration page but it seems that duplicate users (system entity) can be created with the same username when using the application.  How do I ensure that the user (username) is unique ?

Cheers, Richard.

Solution

Richard,

You need to create an action that validates if the username exists first. You can do this by filtering the System/User database table by the username you are trying to save, if something comes back in this collection then you skip the save and let the user know the user already exists.

Keep in mind, if you are creating a multitenant application, you will need to validate against all tenants. You can do this by using the UserMT table. This is the approach we took for our multitenant application, where the assignment is only checking if the GetIntegratedUser is empty.


Andres Moreno

Solution

Hello


I don't know if you have a form that user fill if you do you can just do Andres Moreno sugested and then check if the aggreagate or advance query is empty (does not exists any user with that username) if it not empty then you invalidate the user name input and form and will automaticaly display that validation message you choose.


input.valid = false input.validationmessage= "error here" and then if form valid (that shoudl already be in the save)

Hi Richard Pearce,

You should follow the suggestions above and if you have the chance, open a clone of the Users module and take a look into the logic in it. I'm sure that you're going to learn something new and perhaps you need something of that in your logic.

Thanks,
Samuel

Andres Moreno wrote:

Richard,

You need to create an action that validates if the username exists first. You can do this by filtering the System/User database table by the username you are trying to save, if something comes back in this collection then you skip the save and let the user know the user already exists.

Keep in mind, if you are creating a multitenant application, you will need to validate against all tenants. You can do this by using the UserMT table. This is the approach we took for our multitenant application, where the assignment is only checking if the GetIntegratedUser is empty.


Andres Moreno

Thanks Andres,

I was hoping that I would be able to add something like a unique index on the User entity.  I'll go down the manual validation route as you have suggested.

Cheers, Richard.

Samuel M. wrote:

Hi Richard Pearce,

You should follow the suggestions above and if you have the chance, open a clone of the Users module and take a look into the logic in it. I'm sure that you're going to learn something new and perhaps you need something of that in your logic.

Thanks,
Samuel

Hi Samuel,

That is a little cryptic but I'm guessing you are referring to things like the Is_Active boolean attribute ?

Cheers, Richard.

Richard Pearce wrote:

Andres Moreno wrote:

Richard,

You need to create an action that validates if the username exists first. You can do this by filtering the System/User database table by the username you are trying to save, if something comes back in this collection then you skip the save and let the user know the user already exists.

Keep in mind, if you are creating a multitenant application, you will need to validate against all tenants. You can do this by using the UserMT table. This is the approach we took for our multitenant application, where the assignment is only checking if the GetIntegratedUser is empty.


Andres Moreno

Thanks Andres,

I was hoping that I would be able to add something like a unique index on the User entity.  I'll go down the manual validation route as you have suggested.

Cheers, Richard.

if you dont want to make a validation you can create an new entity with 1 to 1 relation with user and add the same user name to that entity everytime anyone try to create a user. In that table you can put as unique index.


But i think this give a lot more work then validating the user name.

Richard Pearce wrote:

Samuel M. wrote:

Hi Richard Pearce,

You should follow the suggestions above and if you have the chance, open a clone of the Users module and take a look into the logic in it. I'm sure that you're going to learn something new and perhaps you need something of that in your logic.

Thanks,
Samuel

Hi Samuel,

That is a little cryptic but I'm guessing you are referring to things like the Is_Active boolean attribute ?

Cheers, Richard.

Hi again Richard Pearce,

Sorry for confusing you. What I was saying is that already exists some logic to register, edit and delete users. That logic is on the Users Module.
You can view the logic behind that module. Just go to the Service Center->Factory->eSpaces and search for Users. Then download the Module and open it on Service Studio. 

As you can see in the image bellow, the logic that you were looking for is already done and you can copy it.
And perhaps there is some more logic and validations that you may find useful to implement on your screen.

Thanks,
Samuel