         @hide(logout: false, callback: true)
       error: (response) =>
         resp = $.parseJSON(response.responseText)
-          
+
         switch resp.status
           when 422
-            @.$('.input-group').tooltip(
-              placement: 'top'
-              trigger: 'manual'
-              animation: false
-              html: true
-              title: @buildErrors(resp.errors)
-
-            ).tooltip('show')
+            @showTooltip(@buildErrors(resp.errors),true)
+          when 401
+            @showTooltip(@buildErrors(resp.errors),true)
           when 403
             @logoutUser()
           else
-            
-            
-          
+            @logoutUser()
+
+
+
   submitLogin: ->
-    
+
     submitData = {}
     submitData.email = @.$('#session_email').val()
     submitData.password = @.$('#session_password').val()
     submitData.persist_session = true
-    
+
     $.ajax
       type: 'POST'
       url: "/v1/sessions.json"

    @refreshGfx()
    @.$('form').addClass('auth-form-login')
    false
  
  toggleComplete: ->
    @state = 'complete'
    @logoutOnHide = true
    @refreshGfx()
    @.$('form').addClass('auth-form-complete')
    false
  
  
  cancelDialog: () ->
    @hide() if $.inArray(@state, ["complete","password_change","name_change"]) >= 0
  
  logoutUser: ->
    window.location.replace('/logout')
    
  hide: (args) =>
    args = {} unless args
    
    @logoutOnHide = args.logout if args.logout != undefined
    @callbackOnHide = args.callback if args.callback != undefined

    @.$('.modal').modal('hide')
    false
  
  clearLastState: ->
    @.$('form').removeClass('auth-form-login').removeClass('auth-form-register').removeClass('auth-form-restore')
    false
    
  submitFormFromState: (e) ->
    switch @state
      when "restore"          then @submitRestore()
      when "register"         then @submitRegister()
      when "login"            then @submitLogin()
      when "complete"         then @submitComplete()
    
    e.preventDefault()
    false
  
  buildErrors: (errors) ->
    t = "<ul style='text-align: left;'>"
    $.each errors, (index,error) ->
      t += "<li><strong>#{error.ref_node}</strong> #{error.message}</li>" if error.type == "field"
    t += "</ul>"
  
  submitRestore: ->
    
    submitData = {}
    submitData.email = @.$('#session_email').val()
    
    $.ajax
      type: 'POST'
      url: "/v1/users/restore.json"

    submitData.user.email = @.$('#session_email').val()
    submitData.user.password = @.$('#session_password').val()
    submitData.user.confirm_registration = true

    $.ajax
      type: 'PUT'
      url: "/v1/users/#{session.get('user').id}.json"
