diff --git a/resources/static/dialog/controllers/dialog.js b/resources/static/dialog/controllers/dialog.js
index eef6fa57db24f1953a19c019bafdd1c100909caf..380932446cd7e7f1ac3ca8394663f9cd54bfc1d0 100644
--- a/resources/static/dialog/controllers/dialog.js
+++ b/resources/static/dialog/controllers/dialog.js
@@ -64,7 +64,7 @@ BrowserID.Modules.Dialog = (function() {
       email: email,
       verifier: verifier,
       verificationMessage: message
-    }); 
+    });
     controller.startCheck();
   }
 
@@ -245,8 +245,7 @@ BrowserID.Modules.Dialog = (function() {
         user.checkAuthenticationAndSync(function onSuccess() {},
           function onComplete(authenticated) {
             if (self.requiredEmail) {
-              // XXX get this out of here and into the state machine!
-              self.doAuthenticateWithRequiredEmail({
+              self.publish("authenticate_with_required_email", {
                 email: self.requiredEmail,
                 authenticated: authenticated
               });
diff --git a/resources/static/dialog/resources/state_machine.js b/resources/static/dialog/resources/state_machine.js
index eb0f5659677114930724961feffee49165a97160..93704afaa4b29de38ec268911e9eba483211ed6f 100644
--- a/resources/static/dialog/resources/state_machine.js
+++ b/resources/static/dialog/resources/state_machine.js
@@ -55,7 +55,7 @@
     var args = [].slice.call(arguments, 1),
         controller = this.controller;
 
-    // Remember the state and the information for the state in case we have to 
+    // Remember the state and the information for the state in case we have to
     // go back to it.
     stateStack.push({
       funcName: funcName,
@@ -65,7 +65,7 @@
     controller[funcName].apply(controller, args);
   }
 
-  // Used for when the current state is being cancelled and the user wishes to 
+  // Used for when the current state is being cancelled and the user wishes to
   // go to the previous state.
   function popState() {
     // Skip the first state, it is where the user is at now.
@@ -85,7 +85,7 @@
         controller = self.controller,
         gotoState = pushState.bind(self),
         cancelState = popState.bind(self);
-       
+
     subscribe("offline", function(msg, info) {
       gotoState("doOffline");
     });
@@ -102,6 +102,10 @@
       gotoState("doEmailConfirmed");
     });
 
+    subscribe("authenticate_with_required_email", function(msg, info) {
+      gotoState("doAuthenticateWithRequiredEmail", info);
+    });
+
     subscribe("pick_email", function() {
       gotoState("doPickEmail");
     });
@@ -161,7 +165,7 @@
   }
 
   var StateMachine = BrowserID.Class({
-    init: function() { 
+    init: function() {
       // empty
     },
 
@@ -169,7 +173,7 @@
       options = options || {};
       this.controller = options.controller;
       startStateMachine.call(this);
-    }, 
+    },
 
     stop: function() {
       unsubscribeAll();