ContentRepository Save gives 404 in the OWIN SecurityTokenValidated context

Vote:
 

Hi

We use federated authentication and for each user we create a User item (extended from ContentBase). 
In the SecurityTokenValidated context, if the User item is not available, we need to create new User item.

IContentRepository contentRepository = ServiceLocator.Current.GetInstance<IContentRepository>();
OurUser newUser = contentRepository.GetDefault<OurUser>(ourUserContainer);
//Set some properties to new User
contentRepository.Save(newUser, SaveAction.Publish); // Goes to HTTP Error 404

In the server error: Logon User is Anonymous. 

How can we save the new User content in the OWIN SecurityTokenValidated context?

#252036
Edited, Mar 30, 2021 7:09
Vote:
 

Use this -

contentRepository.Save(newUser, SaveAction.Publish,  AccessLevel.NoAccess););
#252159
Mar 30, 2021 8:58
Helani Wanniarachchi - Mar 31, 2021 4:17
Adding AccessLevel.NoAccess did not work, still goes to 404 right after contentRepository.Save(newUser, SaveAction.Publish, AccessLevel.NoAccess);
Vote:
 

I figured the issue, Save just worked fine after assigning a value to newUser.Name property. So it was not any access rights issue but Name is like a mandatory property to save a content. It is bit silly I didn't realise it, but the access denied error just freaked me at first place. Thanks 

#252226
Mar 31, 2021 5:14
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.