CreateUser

  

Hi,


Having a problem creating a user. I have followed past forum conversations and the example HOW2UserRegistration, but with one difference. My user data is coming from a session variable Session.RegistrationStep2, which is of data type User. My module is called Muckingabout.

I believe I have:

1) GrantedMuckingaboutUserRole

2) EncryptPassword

3) Updated the original Session.RegistrationStep2 with the now encypted password

4) Create User

5) RevokedMuckingaboutUserRole


I know that my EncryptPassword is working as I can write to the screen the variable and true enough it is encrypted. However, when I go to User > View Data in my core data module it states there are no record to show, therefore my CreateUser action hasn't worked.

I'm guessing that the problem is something around the fact that I only have values for Username, Password, Email and Phone, or there is a clash between my session variable and the CreateUser.

Pictures:






Cheers

Hamish

What is your actual problem? You get an error message? Or something else?

This code runs with no errors, however when I look for a new record in the entity it's not there. 

Any one have any ideas?

Depends where you expect the record willl be?


1. do you have multi-tenancy?

2. how do you test if the record is there or not.

3. error-logging does not tell you anything?

4. do you perhaps rollback the transaction?


1. do you have multi-tenancy?

Its currently not.

2. how do you test if the record is there or not.

I have been usng 'View data' when right clicking on the entity, where I see no new records.

3. error-logging does not tell you anything?

I only have the out of the box error logging, but doesn't seem to be telling me anything

4. do you perhaps rollback the transaction?

Not sure how to do this?

Hi Hamish,

do you have an Exception Handler in that action that could be hiding problems in the creation of the user?...

Hello Hamish,

1.  Logged user, to create other users, need UsersManager role (afaik).
2. Check if you have an exception handler in the action. If you have, select it (first node) and look at the properties (Log Error and Abort Transaction). Guarantee that you have both set to Yes.
3. If you don't, check in the module properties if the Global Exception Handler is defined. If not, set it, and guarantee that the Log Error is set to Yes.
4. Activate the Debugger and set a breakpoint in the last node of your action. Try to create a new user and see if the code is executed to the node that is the Destination.
5. If your action is executed from a button/link with method set to "Submit", an exception in the destination page's preparation or during its construction step, if catch by any exception handler (in the preparation or in the global exception handler) with the Abort Transaction to Yes will rollback the transaction.
6. In the end, check if your "view" is not using any filter that can prevent data from appearing.

The debug will tell you if you are being able to save the record or not.

Please, after the test, show us the list of the most recent errors in the Service Center. Unless you didn't setup the Global Exception Handler and are not expliciitly saying to  NOT log the errors in any exception handler that is catching exceptions (in the action or in the global exception handler), any error should be logged there.

Cheers.

Hi guys,

Thank you for your knowledge, very useful and I have debugger running.

I have figured out whats happening. The code was working and the record was being made in the database. However, I was expecting the record to appear in the User entity in my core module (which currently has zero records -hence me thinking the sql wasn't working), however its appearing in the User entity of my specific module. I though they would have been the same?

This application is currently single tenant, however I plan to move it into multi-tennant.

From my reading of the training I had planned to develop the application in a modular way, modules being:


Core portal - where all the database schema is defined

Registration - new users register

Main Portal - Users login and use the features of the portal

Management Portal - Managers of clients can see what users have been doing

MI dashboard Portal - Senior managers can view usage information

 

I assumed that it would make sense that all users of the application were saved in the core module. Can you confirm if my logic makes sense or not? If it does how do I get there?


Cheers

Hamish

Hello Hamish,

Entity User, from System, is the entity where the application users must be created. The default authentication and authorization tools all use this entity. So, you don't need to create your own entity User (and can't, really, as it would be a license violation).

Regarding application architecture, please, refer to the following documentation:

https://success.outsystems.com/Support/Enterprise_Customers/Maintenance_and_Operations/Designing_the_architecture_of_your_OutSystems_applications

Cheer.

Hi.


Thanks Eduardo, I understand you point and haven't done this.

What I had assumed was that when I was looking at the User entity under System within one of my modules that it was the same User entity under System within the other modules in the application. i.e. One User Entity stored in my core module exposed to all other modules. That would mean that I have one central view of Users in the application to work from.

How I have it set up makes it appear that I have a User entity in each of modules, which doesn't seem correct?


Cheers

Hamish 

Hamish Price wrote:

What I had assumed was that when I was looking at the User entity under System within one of my modules that it was the same User entity under System within the other modules in the application. i.e. One User Entity stored in my core module exposed to all other modules. That would mean that I have one central view of Users in the application to work from.

How I have it set up makes it appear that I have a User entity in each of modules, which doesn't seem correct?


Cheers

Hamish 

Hamish, 

User entity is under System. It is the SAME entity in any module that references it.
So, if you mark to use it in Manage Dependencies in Module A, and mark it in Manage Dependences in Module B, both modules will see the exact same data (if both are not multi tenant, in which the data for different tenants will be isolated, but the entity will be the same).

The User entity is central to ALL modules in all applications in an OutSystems environment.

So, I am not understand your affirmation...

If you CREATE an User entity in one of your modules, than it is not the same as the User in System. 

Could you explain a little more what are you doing with entities? I got lost here... :)

Cheers


Hi Hamish,

Can you please check what value your Module has in its User Provider module property? It should be Users, but I suspect yours says (Current eSpace).

Very good, Jorge!

I never remember the developer can change the user provider for the Current eSpace, and by the description of Hamish, it's almost for sure that it is... lol

That property is commonly forgotten. It usualy set it auto to 'Current eSpace' if you create a blank module.
(happens to me many times)

Hi Hamish,

Have you sorted out your issue? if so, can you please share your solution or mark the post that helped you fix it so others can learn from this as well?

Thanks!

Morning guys.

Thank you for your support.

I have checked the User provider module on the consuming module and it was Users. There was a second recommended option that was ServiceCentre, but I ignored that.

To double check I am reading the situation correctly:

1) I am using the personal version of the product (so aware I can see users of other peoples personal versions as well)

2) I have created a module (muckingabout) that allows me to create a user. Within the data view of the module if a right click on the System > Users I see the record (I've only made the one user at this time, so 1 record.

3) If I open my core module and within data view of the core module I right click on System > User I see zero records. Unless there some access permission thing with the platform that stops me seeing users in the core, my conclusion is that the application isn;t sharing the core user entity as required.

4) If I go to dependencies with my muckingabout module I have my core module ticked and also lower in the list I have Users ticked. Note: Within the list of my core dependencies there is no option to choose System > User, so I assume this happens within the platform behind the scenes?

5) Within the core module the Users entity is exposed as Read Only No.

Pictures:



Solution

Hi Hamish,

in your DSRPortal_Core_V2 module, your User Provider module property is set to (Current eSpace). Switch it back to Users and everything should be sorted out.

Solution

Ok.

Some new news. As part of testing out what is happening I created another module with in the application. When I go to Data > System within this module and View Data in the Uer entity I do get to see the user that was created in my other module. This would indicate that the problem is with being able to view data in the system entity in the core module?

Hamish

Winner winner, chicken dinner!

Thanks Jorge. I had checked the consuming modules but not the core. Thank you for your support.

Hamish