title: ServiceStack response after a successful authentication throws error. what is missing?
body: <p>I used a restconsole to post:</p>
  
  <pre><code>http://MyApp/auth/credentials
  </code></pre>
  
  <p>My Custom AuthProvider below:</p>
  
  <pre><code> public class MyAppCredentialsAuthProvider : CredentialsAuthProvider
  {
  
      public override bool TryAuthenticate(IServiceBase authService,
      string userName, string password)
      {         
          //Add here your custom auth logic (database calls etc)
          //Return true if credentials are valid, otherwise false
  
          SetUp();
  
          var userDao = _appHost.Container.Resolve&lt;IUserDao&gt;();
          bool isValid = false;
  
          if (string.IsNullOrEmpty(userName))
              return false;
  
          if (string.IsNullOrEmpty(password))
              return false;
  
          var user = userDao.GetUserByUsername(userName);
  
          if (user == null)
              return false;
  
          if (string.IsNullOrEmpty(user.Password))
              return false;
  
          if (CheckPassword(password, user.Password))
          {
              bool isApproved = user.IsApproved;
              if (isApproved &amp;&amp; user.Status == (short)Status.Active)
              {
                  isValid = true;
                  user.IsOnLine = true;
                  user.LastLoginDate = DateTime.Now;
                  userDao.Update(user);
              }
          }
          return isValid;
      }
  
      public override void OnAuthenticated(IServiceBase authService,
          IAuthSession session, IOAuthTokens tokens,
          Dictionary&lt;string, string&gt; authInfo)
      {
          try
          {
              // Authenticate the user.
              var userRepo = authService.TryResolve&lt;IUserDao&gt;();
              var user = userRepo.GetUserByUsername(session.UserAuthName);
  
              session.LastName = user.Lastname;
              session.UserName = user.Username;
              session.Email = user.UserEmail;
              session.DisplayName = user.Lastname + " " + user.Othernames;
              session.IsAuthenticated = true;
  
              //Important: You need to save the session!
              SessionExpiry = new TimeSpan(0, 5, 0);
              authService.SaveSession(session, SessionExpiry);
          }
          catch (Exception exc)
          {
              // log error
          }
  
      }
  
  
      public void SetUp()
      {
          _appHost = new BasicAppHost().Init();
          var container = _appHost.Container;
  
          var dbFactory = new OrmLiteConnectionFactory(ConfigurationManager.ConnectionStrings["MyAppDB"].ConnectionString, SqlServerDialect.Provider);
          container.Register&lt;IDbConnectionFactory&gt;(dbFactory);
          container.RegisterAutoWiredAs&lt;UserDao, IUserDao&gt;();            
      }
      }
  </code></pre>
  
  <p>After execution exists public override void OnAuthenticated(...)</p>
  
  <p>I get the error below:</p>
  
  <pre><code>Server Error in '/' Application.
  Object reference not set to an instance of an object.
  
  Stack Trace: 
  
  
  [NullReferenceException: Object reference not set to an instance of an object.]
     ServiceStack.WebHost.Endpoints.Support.EndpointHandlerBase.HandleException(IHttpRequest httpReq, IHttpResponse httpRes, String operationName, Exception ex) +206
     ServiceStack.WebHost.Endpoints.RestHandler.ProcessRequest(IHttpRequest httpReq, IHttpResponse httpRes, String operationName) +1058
     ServiceStack.WebHost.Endpoints.Support.EndpointHandlerBase.ProcessRequest(HttpContext context) +264
     System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +341
     System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp; completedSynchronously) +69
  </code></pre>
  
  <p>What params or configuration or step am i missing?</p>
  
  <p>Thanks.</p>