 
       success: ({token}={}) =>
         if token?.length > 0
+          @signedInUser = username
           unless keytar.replacePassword('github.com', 'github', token)
             console.warn 'Unable to save GitHub token to keychain'
         @detach()

ScrollView = require 'scroll-view'
keytar = require 'keytar'

module.exports =
class SignInView extends ScrollView
  @activate: ->
    new SignInView()

  @content: ->
    @div class: 'sign-in-view overlay from-top', =>
      @h4 'Sign in to GitHub'

        @alert.text(message).show()

  attach: ->
    if @signedInUser?
      @username.val(@signedInUser)
    else
      @username.val('')

    @password.val('')
    @setElementEnabled(@username, true)
    @setElementEnabled(@password, true)
    @alert.hide()
    rootView.append(this)

    if @signedInUser?
      @password.focus()
    else
      @username.focus()

module.exports =
  signInView: null

  activate: (state) ->
    @signInView = new SignInView(state)

  deactivate: ->
    @signInView?.remove()
    @signInView = null

  serialize: ->
    if @signInView?
      @signInView.serialize()
    else
      @state
