Create "User Registration Page" 

Create "User Registration Page" 

  
Hi,

Is there a user "Registration Page" alreagy built into the London theme or any other theme? If not, is there an example of one (or espace) or does it exist in forge? I would like to create a registration pages that validates if the user exists and then assigns the new user to a role and/or group.

Any help would be appreciated.

Thanks,
Fadi
Hello Fadi.

Creating a page that allow a user to do a self registration is as simple as creating a new page, add an edit record and drop the User entity inside the edit record.

On the "Save" action you will need to implement the logic that you find necessary, for instance, validating that there's no one else registred with the given username.

Also keep in mind that there's a system action that creates a new User and fails if there's a user with the given username in the system. You can find that action in the Users eSpace. That action should be used to create the user. To be able to invoke that action you will need to grant the Usermanager Role. As you might be guessing, the user that is executing the action is unknow so, you will grant the role during the action and then revoke it before the action ends.

Hope it helps!
Pedro 


Thanks Pedro,

I tried some of those things before posting this, I thought there may have been some predone work on that. Any idea if there is a predone espace/template?
I think you can check the eCommerce app in the sample apps in the catalog (in the development studio, check the first "outsystems" tab). That one has a self registration for users to be able to sign in.


But again... it will depend a lot on your site's/app's use case for self registration. I have another example which asks for some other info in the middle of the self registration part... The important thing is what you want to collect. Registering the user and assigning him a particular role is all done with the standard apis.


Sweet, thanks guys
Just bumped into this thread, and found this HowTo app by Stacey Levine, that might be helpful http://www.outsystems.com/forge/component/903/how2userregistration/

Cheers,

Pedro Cardoso wrote:

Hello Fadi.

Creating a page that allow a user to do a self registration is as simple as creating a new page, add an edit record and drop the User entity inside the edit record.

On the "Save" action you will need to implement the logic that you find necessary, for instance, validating that there's no one else registred with the given username.

Also keep in mind that there's a system action that creates a new User and fails if there's a user with the given username in the system. You can find that action in the Users eSpace. That action should be used to create the user. To be able to invoke that action you will need to grant the Usermanager Role. As you might be guessing, the user that is executing the action is unknow so, you will grant the role during the action and then revoke it before the action ends.

Hope it helps!
Pedro



Hi Pedro,

I followed your instructions to create a self-registration page and was successful... However when I drag and drop the "User" entity into the form, I get attributes like "External", "Creation Date" , "Last Login" and "Is_Active" (See attached Image) ... Obviously I don't want my users to be able to edit any of that. How do I hide those attributes and set them automatically? Or, even better, how to I edit the attributes of the built in "User" entity? 

Finally, how do I model my system so that the system's "User" entity represents the data for my own "Client" entity? I'm having trouble understanding how you can create an entity to model a client and have login-accounts for that client entity based on the System's default "User" entity. 

Apologies for the long-winded and multi-faceted question.

- Justin


Hey Justin, no worries, keep asking! Glad to help!


To remove those attributes from the UI you just need to delete the input boxes from the UI, along with any container that you don't need any more. If those attributes are not present in the UI, the user won't be able to set them, and they are not updated in the database. Then, in your own logic, you need to build your own business logic. For example, you can set the is_active as false by default so that you can review the self registration in a backoffice and set it to true only if it's not a bot. To do that, we usually check if the User.Id is not set, equal to NullIdentifier, and  if that is true, then you now it's a new user and you simply set it in an assign. 

Regarding modeling the User entity so that it contains the attributes that you need, for example, a birthdate, we usually create a new entity with the attributes that we need with a subtle change: the Identifier of this new entity is of the type UserId. This way, you create a 1-1 relationship between the system User entity and your UserExt (that's the name some of the guys use to use). The built in login mechanisms keep working, and you have the needed attributes in place :)  More than that, our aggregates are smart enough to understand that whenever you need to query the User entity, you probably need your UserExt, or whatever you call it


Cheers!

Ah thanks Pedro, that helps a lot! The only attribute that my extended "Client" entity has which the User entity doesn't is "Surname"... Then I will just have a "Client" entity with the "Surname" attribute and link it via a 1-1 relationship with the system's User entity?


I've done that and I have also changed my entity structures quite a bit... but now I'm getting a LOT of database integrity errors. Is there a quick and easy method to force OutSystems to update the DB to match my new entity structure? Or even just to wipe the DB clean and start it again using my new entity structure? How would you suggest I go about handling this?

I guess you're referring to that warning stating that there are fields in the database that are not in the entity right? Try to use this https://www.outsystems.com/forge/component/423/dbcleaner/

Thanks! The problem was that we had renamed entities rather than deleting them and recreating them... And we had renamed attributes instead of deleting them. 

That's the usual way to go. You just need to clean them afterwards.