     this
 
   logout: ->
-    newElement = jQuery(@template)
-
-    @element.replaceWith newElement
-    @element = newElement
+    @element.removeClass(@classes.loggedIn).html(@template)
 
     @user = null
-    @updateBook @book
-
-    this.publish "disconnect", this
+    @updateBook()
+
+    @publish "disconnect", [this]
 
   updateUser: (@user=@user) ->
     if @user


  authorize: (@accessToken) ->

  isAuthorized: -> !!@accessToken

class Store

    loggedIn: "annotator-readmill-logged-in"

  template: """
  <a class="annotator-readmill-avatar" href="" target="_blank">
    <img src="" />
  </a>
  <div class="annotator-readmill-user">
    <span class="annotator-readmill-fullname"></span>
    <span class="annotator-readmill-username"></span>
  </div>
  <div class="annotator-readmill-book"></div>
  <div class="annotator-readmill-connect">
    <a href="#">Connect with Readmill</a>
  </div>
  <div class="annotator-readmill-logout">
    <a href="#">Log Out</a>
  </div>
  """

  constructor: () ->
    super jQuery("<div class=\"annotator-readmill\">").html(@template)

  connect: ->
    @publish "connect", [this]

  login: (user) ->
    @updateUser(user) if user
