File: token.coffee

Defined in: lib/resin/token

Method Summary

Method Details

~ (void) saveToken(newToken, callback)

TODO: We should make the token more secure
Note: The token is saved as plain text.

Save token

The token is saved to $(dataPrefix)/token, which usually equals to $HOME/.resin/token

resin.token.saveToken myToken, (error) ->    throw error if error?

Parameters:

  • newToken ( String ) the token
  • callback ( Function ) callback(error)

~ (void) hasToken(callback)

Check if we have any token saved

resin.token.hasToken (hasToken) ->    if hasToken
        console.log('It\'s there!')    else
        console.log('It\'s not there!')

Parameters:

  • callback ( Function ) callback(hasToken)

~ (void) getToken(callback)

Note: If the key doesn't exist, undefined and no error is returned

Get saved token value

resin.token.getToken (error, token) ->    throw error if error?    if token?
        console.log("My token is: #{token}")

Parameters:

  • callback ( Function ) callback(error, token)

~ (void) clearToken(callback)

Note: If the token doesn't exist, no action is performed

Remove token from the filesystem

resin.token.clearToken (error) ->    throw error if error?

Parameters:

  • callback ( Function ) callback(error)

    Quickly fuzzy find classes, mixins, methods, file:

    Control the navigation frame:

    You can focus and blur the search input: