user2033791
user2033791

Reputation: 840

Authentication using ServiceStack 4.5.14

I'm working off of the SocialBootstrap API example (using ServiceStack 4.5.14) and trying to get authentication to work. Registration works fine, the user account get's created in the DB without any problem, but when I try to use the newly created user to login I get "Invalid Username or Password". When I step through my code the correct username and password are being passed. My code on signup looks like:

using (var authService = HostContext.ResolveService<AuthenticateService>())
{
    //authenticate with servicestack
    var response = authService.Authenticate(new Authenticate
    {
        provider = CredentialsAuthProvider.Name,
        UserName = model.Username,
        Password = model.Password,
        RememberMe = model.RemeberMe
    });

    ...

It hits the authenticate method and then goes to:

container.Register<IDbConnectionFactory>(
    new OrmLiteConnectionFactory(connStr, //ConnectionString in Web.Config
        SqlServerDialect.Provider)
    {
        ConnectionFilter = x => new ProfiledDbConnection(x, Profiler.Current)
    });

in AppHost.cs. After this it throws the "Invalid username or password error". I can't figure out why it won't authenticate. With the exception of using SQL Server instead of Postgres the code is basically identical to the example. I know my SQL connection works and the connection string is OK because registration works flawlessly. I just am at a loss to see what else I can do to make the login work. Can anyone shed some light on what I've done wrong or something else I can try to find my error?

Upvotes: 1

Views: 122

Answers (1)

mythz
mythz

Reputation: 143399

I've just tried the SocialBootstrapApi project. Installed the ServiceStack.OrmLite.SqlServer package, replaced the OrmLiteConnectionFactory to use SQL Server:

container.Register<IDbConnectionFactory>(
    new OrmLiteConnectionFactory(connString, SqlServerDialect.Provider)
    {
        ConnectionFilter = x => new ProfiledDbConnection(x, Profiler.Current)
    });

Then was able register a new User with Email [email protected] and Password test which logs straight in:

enter image description here

Logging out and Signing In also works as expected.

Upvotes: 1

Related Questions