Pedro Cardoso wrote:
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.
is it possible to do a forgot/reset password method for users?