Tyson
Tyson

Reputation: 14734

Creating new ServiceStack users via the RegistrationService within an existing user's session

This requirement has come up due to an invitation feature where an existing 'inviter user' invites a new 'invitee user' (it is different to a normal email invitation system as the inviter must set certain roles on the invitee's account, so the account must exist before the invitee reads the email and follows the link).

So following on from my previous question regarding calling the RegistrationService from my InvitationService, I've got the message forwarding aspect working. But now the RegistrationService seems to make an assumption that you are either creating a new user for the current session, or updating the current session's user details.

This causes an issue for my invitation service, as rather than creating a new invitee user the inviter's UserAuth is updated with the invitee's details.

Now I can create a new InviteeRegistrationService, which will basically do exactly the same as RegistrationService except for that existing user check (well it will probably still do the existing user check but return an 'already invited' response instead), but I don't really want to duplicate all that registration code and maintain the duplicate.

Is there any tricks/workarounds for this edge case? Or an actual feature that allows me to do this that I have missed?

Upvotes: 1

Views: 133

Answers (1)

mythz
mythz

Reputation: 143319

Since ServiceStack is all open source, if you have special requirements, you're better off just taking a copy of the existing code and modify it to suit your needs. This is better than trying to abstract the RegistrationService so it tries to meet everyone's requirements, which in-turn makes it harder to read and understand for everyone.

Don't worry about code-duplication, as you have different requirements - start with the code from the RegistrationService as a template and change to suit your needs.

Upvotes: 1

Related Questions