             false
 
     # Clear the authentication status when we type
-    $('#form-authenticate input').bind 'input',  -> clearAuthentication()
+    $('#form-authenticate input').bind 'input', ->
+        $('#form-authenticate').removeClass 'success fail'
+        $('#userbar').empty()
 
     # Todo: .live is deprecated
     $('tbody tr').live 'click', ->

    @login = undefined
    @password = undefined

    # Index
    @get '/', ->
        @$element().html 'Haha, this is the index :)'

    # List samples
    @get '/samples', ->
        $.ajax '/api/v1/samples',
            beforeSend: addAuthHeader
            success: (r) => @partial '/templates/samples.mustache', r
            statusCode: statusHandlers this
            dataType: 'json'

    # Show sample
    @get '/samples/:sample', ->
        $.ajax "/api/v1/samples/#{ @params['sample'] }",
            beforeSend: addAuthHeader
            success: (r) => @partial '/templates/sample.mustache', r
            statusCode: statusHandlers this
            dataType: 'json'

    # Authentication event
    @bind 'authentication', =>
        $('#form-authenticate').removeClass 'success fail'
        $('#userbar').empty()
        if @user?
            state = 'success'
            $('#userbar').append $("<h3>#{ @user.name }</h3>
                                    <p>Roles: #{ @user.roles.join ', ' }</p>")
        else
            state = 'fail'
        $('#form-authenticate').addClass state
        @refresh()


