File: auth.coffee

Defined in: lib/resin/auth

Method Summary

Method Details

~ (void) authenticate(credentials, callback) Private

Note: You should use login() when possible, as it takes care of saving the token as well.

Authenticate with the server

resin.auth.authenticate credentials, (error, token) ->    throw error if error?    console.log(token)

Parameters:

  • credentials ( Object ) in the form of username, password
  • callback ( Function ) callback (error, token)

Options Hash: (credentials):

  • username ( String ) the username
  • password ( String ) user password

~ (void) login(credentials, callback)

Note: This function saves the token to the directory configured in dataPrefix

Login to Resin.io

Is the login is successful, the token is persisted between sessions.

resin.auth.login credentials, (error) ->    throw error if error?    console.log('I\'m logged in!')

Parameters:

  • credentials ( Object ) in the form of username, password
  • callback ( Function ) callback (error)

Options Hash: (credentials):

  • username ( String ) the username
  • password ( String ) user password

~ (void) isLoggedIn(callback)

Check if you're logged in

resin.auth.isLoggedIn (isLoggedIn) ->    if isLoggedIn
        console.log('I\'m in!')    else
        console.log('Too bad!')

Parameters:

  • callback ( Function ) callback (isLoggedIn)

~ (void) getToken(callback)

Note: This function simply delegates to resin.token.getToken() for convenience

Get current logged in user's token

resin.auth.getToken (error, token) ->    throw error if error?    console.log(token)

Parameters:

  • callback ( Function ) callback (error, isLoggedIn)

~ (void) logout(callback)

TODO: Maybe we should post to /logout or something to invalidate the token on the server?

Logout from Resin.io

resin.auth.logout (error) ->    throw error if error?    console.log('I\'m out!')

Parameters:

  • callback ( Function ) callback (error)

~ (void) parseCredentials(credentials, callback) Private

Parse colon separated credentials

resin.auth.parseCredentials 'johndoe:secret', (error, credentials) ->    throw error if error?    console.log(credentials.username)    console.log(credentials.password)

Parameters:

  • colon ( String ) separated credentials (username:password)
  • callback ( Function ) callback (error, credentials)

    Quickly fuzzy find classes, mixins, methods, file:

    Control the navigation frame:

    You can focus and blur the search input: