Sandstorm.UserManagement: routing problems - "Unexpected user type "%s". An account with the identifier "%s" exists, but the corresponding party is not a Neos User"

Hi Guys,

I have to implement a frontend user management at a Neos website and therefore Sandstorm.UserManagement seems to be perfect.

As I’m using the package in Neos, on the one hand it seems to be recommended to use the implementation of the Redirect and User Creation Services of the Neos services. But on the other hand the default user model has to be extended with two custom fields, and these custom fields have to be also visable and changeable in the Neos backend.
I assume that an extension of the Neos User Creation Service and user model (db table "party_domain_model_personname?) is not easy and I think, that a separation of frontend- and backend-users would be fine, so my idea is to create a custom Neos backend module lateron and at first I already changed the user model like proposed here. Do you agree that that’s a useful strategy?

The registration process now works for me; users are persisted in a seperate database table with the custom fields.
The problem now is, that when I try to log in over the Login Form in frontend, I get this 500er error:

Could not convert target type "Neos\ContentRepository\Domain\Model\NodeInterface": Warning: get_class() expects parameter 1 to be object, null given in /var/www/vhosts/my.domain/MySite/Neos/Data/Temporary/Development/Cache/Code/Flow_Object_Classes/Neos_Neos_Domain_Service_UserService.php line 877

Exception Code 1297759968
Exception Type Neos\Flow\Property\Exception
Log Reference 202106031937013884e7
Thrown in File Data/Temporary/Development/Cache/Code/Flow_Object_Classes/Neos_Flow_Property_PropertyMapper.php
Line 129
Original File Packages/Framework/Neos.Flow/Classes/Property/PropertyMapper.php
Nested Exception

Warning: get_class() expects parameter 1 to be object, null given in /var/www/vhosts/my.domain/MySite/Neos/Data/Temporary/Development/Cache/Code/Flow_Object_Classes/Neos_Neos_Domain_Service_UserService.php line 877
Exception Code 1
Exception Type Neos\Flow\Error\Exception
Log Reference 20210603193701db3601
Thrown in File Packages/Framework/Neos.Flow/Classes/Error/ErrorHandler.php
Line 81

get_class()

Data/Temporary/Development/Cache/Code/Flow_Object_Classes/Neos_Neos_Domain_Service_UserService.php
Original File: Packages/Application/Neos.Neos/Classes/Domain/Service/UserService.php
00875:         $user = $this->partyService->getAssignedPartyOfAccount($account);
00876:         if (!$user instanceof User) {
00877:             throw new Exception(sprintf('Unexpected user type "%s". An account with the identifier "%s" exists, but the corresponding party is not a Neos User.', get_class($user), $username), 1422270948);
00878:         }
00879: 

When I try to login “directly over the flow package”, so over the URL my.domain/login , it works, but in frontend I only see the html of the UserManagement package (sandstorm/UserManagement/Resources/Private/Templates/Login/Login.html)!
But if I try over the URL my.domain/login.html (the Neos page with the login form), I get the errors mentioned above.

So it seems to be a routing problem. Any idea what I’m doing wrong?

Hey @itoop,

sorry for the late response. Just to let you know, I’ve brought this up to the team and they will get back to this topic soon!

sunny regards
Fabian from Sandstorm

Hi @tschoeki ,
thank you for the status update and have a nice weekend.