Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding an auth client #48

Merged
merged 17 commits into from Feb 11, 2016

Conversation

Projects
None yet
2 participants
@ekryski
Copy link
Member

ekryski commented Feb 11, 2016

This adds an authentication client that makes it simple to authenticate with feathers.

Using it is as simple as:

var socket = io(host, {
  transport: ['websockets']
});

window.app = feathers()
  .configure(feathers.socketio(socket))
  .configure(feathers.hooks())
  .configure(feathers.authentication());

app.io.on('connect', function(){
  app.authenticate({
    type: 'local',
    'email': 'admin@feathersjs.com',
    'password': 'admin'
  }).then(function(result){
    console.log('Authenticated!', result);
  }).catch(function(error){
    console.error('Error authenticating!', error);
  });
});

included

  • app.authenticate() - authenticates a user over rest or sockets using local or token auth. This automatically checks localstorage with fallback to cookie for the JWT stores the token and user in local storage upon success.
  • app.logout() - logs out a user destroying the user and token in local storage
  • app.user() - a convenience method for getting the current user
  • token is included in hook.params.token so it can be access by hooks and services on the client and sent to the server.
  • user is included in hook.params.user so it can be access by hooks and services on the client and sent to the server.
@ekryski

This comment has been minimized.

Copy link
Member Author

ekryski commented Feb 11, 2016

This refs #44

@ekryski ekryski referenced this pull request Feb 11, 2016

Closed

Add a client side component for authentication #44

12 of 12 tasks complete
throw new Error(`Unsupported authentication 'type': ${options.type}`);
}

// return new Promise(function(resolve, reject) {

This comment has been minimized.

@ekryski

ekryski Feb 11, 2016

Author Member

I left this in here to see if @daffl feels like taking a crack at Promise hell. The intention is to see if we can make it so the developer doesn't have to wrap app.authenticate() in a callback after socket connection.

@marshallswain

This comment has been minimized.

Copy link
Member

marshallswain commented Feb 11, 2016

Well, that's one hell of a pretty API. 👍 Nice work, @ekryski.

ekryski added a commit that referenced this pull request Feb 11, 2016

Merge pull request #48 from feathersjs/client
Adding an auth client

@ekryski ekryski merged commit 079a43f into decoupling Feb 11, 2016

0 of 2 checks passed

continuous-integration/travis-ci/pr The Travis CI build failed
Details
continuous-integration/travis-ci/push The Travis CI build failed
Details

@ekryski ekryski deleted the client branch Feb 11, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.