title: Logged in user's context being used in a new conversation too while using botauth with Azure table storage
body: <p>I am using <a href="https://github.com/MicrosoftDX/botauth/tree/master/CSharp" rel="nofollow noreferrer">BotAuth</a> to login users on my bot. Recently I implemented Azure Table storage to store and manage bot’s state data, by following the steps mentioned in <a href="https://docs.microsoft.com/en-us/bot-framework/dotnet/bot-builder-dotnet-state-azure-table-storage" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/bot-framework/dotnet/bot-builder-dotnet-state-azure-table-storage</a>.</p>
  
  <p>My Global.asax.cs file looks like this :</p>
  
  <pre><code>protected void Application_Start(object sender, EventArgs e)
      {
          {
              var config = GlobalConfiguration.Configuration;
              Conversation.UpdateContainer(
                  builder =&gt;
                  {
                      builder.RegisterModule(new AzureModule(Assembly.GetExecutingAssembly()));
  
                      var store = new TableBotDataStore(ConfigurationManager.AppSettings["StorageConnectionString"], "botfactoryestimatorstate");
                      builder.Register(c =&gt; store)
                          .Keyed&lt;IBotDataStore&lt;BotData&gt;&gt;(AzureModule.Key_DataStore)
                          .AsSelf()
                          .SingleInstance();
  
                      builder.Register(c =&gt; new CachingBotDataStore(store,
                                   CachingBotDataStoreConsistencyPolicy.ETagBasedConsistency))
                           .As&lt;IBotDataStore&lt;BotData&gt;&gt;()
                           .AsSelf()
                           .InstancePerLifetimeScope();
                      // Register your Web API controllers.
                      builder.RegisterApiControllers(Assembly.GetExecutingAssembly());
                      builder.RegisterWebApiFilterProvider(config);
  
                  });
  
              config.DependencyResolver = new AutofacWebApiDependencyResolver(Conversation.Container);
          }
  
          // WebApiConfig stuff
          GlobalConfiguration.Configure(config =&gt;
          {
              config.MapHttpAttributeRoutes();
  
              config.Routes.MapHttpRoute(
                  name: "DefaultApi",
                  routeTemplate: "api/{controller}/{id}",
                  defaults: new { id = RouteParameter.Optional }
              );
          });
      }
  </code></pre>
  
  <p>And <strong>MessagesController</strong> is same as the one in the bot template, no changes there.</p>
  
  <p>On testing it in 2 emulator windows, one after the other, I notice that the first emulator prompts for login, while the other emulator window is taking in the context automatically, and not prompting in for authentication :
  <a href="https://i.stack.imgur.com/nGIo0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nGIo0.png" alt="enter image description here"></a></p>
  
  <p>On Debugging it, I found that <code>context.UserData.TryGetValue($"{this.authProvider.Name}{ContextConstants.AuthResultKey}", out authResult)</code> code in botauth returns values always, after any user is authenticated.</p>
  
  <p>But when I change from the state management in azure table to use the old state management by bot framework, I get the expected behavior.
  <a href="https://i.stack.imgur.com/JyWPC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JyWPC.png" alt="enter image description here"></a></p>
  
  <p>What exactly am I missing? Is it some autofac module registration. Does anyone have a perfectly working sample for this.</p>