Developer forum

Forum » Development » How to create and save users?

How to create and save users?


Reply

Hi,
 
I'm trying to create and save users by using the API...

var user = new User();
// setting property values here
user.Save();

This works... but not without side effects :/

When a user is saved, that user is set as the current user. How can i avoid that? 

Changing the current user when saving a user makes no sense to me.
If you need to change the current user context when users register in frontend, could it be done in a separate method and not in the save method? :)

(19.2.1.3)

BR.
Morten

Replies

 
Nicolai Høeg Pedersen
Reply
That is a bug.

Just fixed it so current user is only updated if the user changed is current user.

TFS6287 - out with next hotfix (19.2.1.7)
 
Reply
The UserSync web service also fails when it calls User.Save()

I think that is because you are accessing the session when no session is available.

"...the Context.Session property will be null if EnableSession is not explicitly set to True for a particular Web method."

http://msdn.microsoft.com/en-us/library/aa480509.aspx
 
Aki Ruuskanen
Reply
 I have this problem in 19.2.2.1.

/Aki
 
Nicolai Høeg Pedersen
Reply
Which of the issues?

The webservice or save issue?

 
Aki Ruuskanen
Reply
 Sorry, the issue with creating and saving a new user.

/Aki
 
Nicolai Høeg Pedersen
Reply
Hi Aki

So when you save a different user than the one you are logged in with, current user is changed?

Or do you experience another problem?

BR Nicolai

 
Aki Ruuskanen
Reply
When a user is logged in to frontend and creating a new user with the API the session gets messed up.


 
Nicolai Høeg Pedersen
Reply
Please describe "messed up".

I'm good at a lot of things, but not guessing :-)

 
Aki Ruuskanen
Reply
 We are building a custom admin for a customer.

In that admin we have a place where they can create new users.

When a  user is logged in to the custom admin (using the Extranet/Intranet modul) and try to create a new user (using the API) the logged in users session is lost.

The Save()  method of the User object in the Dynamicweb API does something with the logged in users session.


/Aki

 
Aki Ruuskanen
Reply
 Basically the same problem that in the first post. But we run version 19.2.2.1.

/Aki

 
Nicolai Høeg Pedersen
Reply
Just checked the code and found one more error.

I have made a fix which will be available with next hotfix or service release from us.

 

You must be logged in to post in the forum