4

I was working with out of the box authentication, with service stack, and it works great. So, right now, I am mocking up a user with the following lines of code, taken from ServiceStack examples:

            var userRep = new InMemoryAuthRepository();
            container.Register<IUserAuthRepository>(userRep);
            string hash;
            string salt;
            new SaltedHash().GetHashAndSaltString("test", out hash, out salt);
            userRep.CreateUserAuth(new UserAuth
            {
                Id = 1,
                DisplayName = "DisplayName",
                Email = "as@if.com",
                UserName = "john",
                FirstName = "FirstName",
                LastName = "LastName",
                PasswordHash = hash,
                Salt = salt,
            }, "test");

Is there someway I can define the fields in userRep? For example, lets say I want to have the field portalid as well as part of the UserAuth object? How would I go about doing this? Can I just modify the InMemoryAuthRepository class?

Suraj
  • 271
  • 1
  • 10

1 Answers1

0

You can't change the Schema of ServiceStack's built-in UserAuth DTOs, but it does provide a few extensibility points which are explained in detail in this answer where you could use the RefId and RefIdStr fields to reference your own custom tables or add metadata in the UserAuth row by adding metadata to the Dictionary<string,string> Meta collection.

Community
  • 1
  • 1
mythz
  • 141,670
  • 29
  • 246
  • 390
  • I looked at that example, but I don't think I fully understood. It's probably because of my infantile understanding, but how does creating a customer user session with the parameters of my choice help me? – Suraj Jan 31 '13 at 18:28
  • Help you do what exactly? I've only mentioned that you can't change the built-in UserAuth schema, you can only extend it with the hooks described above. – mythz Jan 31 '13 at 19:17