How should one extend SS/Auth/RegisterService functionality?

I just got the Mvc.sln/Authentication example working and in the Home->Index.cshtml there is a register action…

form id=“form-register” action="/api/register" method=“POST”

That route isn’t mapped anywhere in the Solution, it seems to be in…

ServiceStack/Auth/RegisterService.cs

Question 1: Where in the SS code does this code get ‘mapped’ to “api/register”? I think it has something to do with [DefaultRequest(typeof(Register))]?

Question 2: What is the proper way to ‘override’ this RegisterService functionality? (As a simple example let’s say we want to improve the validation, and maybe check some other user DB to make sure this is not a duplicate registration.) My instinct would be to add an ‘api/register1’ route, then copy all this RegisterService code to my project and hack it, but there has got to be a better way?

I’m totally new to ServiceStack and these forums; feel free to tell me if I’m not ‘appropriate’. :slight_smile:

The route is from the RegistrationFeature which is very basic:

public class RegistrationFeature : IPlugin
{
    public string AtRestPath { get; set; }

    public RegistrationFeature()
    {
        this.AtRestPath = "/register";
    }

    public void Register(IAppHost appHost)
    {
        appHost.RegisterService<RegisterService>(AtRestPath);
        appHost.RegisterAs<RegistrationValidator, IValidator<Register>>();
    }
}

If you only need to execute some custom logic you can override the OnRegistered() events in Auth/Session Events to add your own custom logic.

Otherwise the most flexible way to customize the registration Service is to take a copy of the RegisterService and use this instead of the built-in Service.

1 Like