Skip to content
This repository has been archived by the owner on Apr 23, 2019. It is now read-only.

Re-authenticating fails when passing options #22

Closed
juanchristensen opened this issue Jan 18, 2017 · 5 comments
Closed

Re-authenticating fails when passing options #22

juanchristensen opened this issue Jan 18, 2017 · 5 comments

Comments

@juanchristensen
Copy link

Steps to reproduce

1- Authenticate using the local strategy.

app.authenticate({
      strategy: 'local',
      'email': email,
      'password': password
    })

2- Navigate to another page.

3- The jwt token is obtained successfully and is available when calling app.passport.getJWT(), and verifies successfully when calling app.passport.verifyJWT(token).

4- Try to re-authenticate, passing jwt as the strategy.

app.authenticate({
      strategy: 'jwt'
    });

Expected behavior

The re-authentication should succeed.

Actual behavior

Re-authentication fails.
Calling authenticate() without any options works correctly.

System configuration

Module versions: feathers-authentication-client 0.1.6

NodeJS version: 6.9.4

@marshallswain
Copy link
Member

If you're going to pass options, you need to pass all of the ones required for the strategy you're using. The accessToken is missing from the options you're passing. This is behavior that was also available in the original auth, and we've kept it around.

@daffl
Copy link
Member

daffl commented Jan 18, 2017

If you don't pass anything (like app.authenticate()) it will try to authenticate with the token from storage though right?

@daffl
Copy link
Member

daffl commented Mar 7, 2017

As pointed out, you either call app.authenticate() with no options which will use the token from storage or the full options with

app.authenticate({
  strategy: 'jwt',
  token: 'mytoken'
});

@daffl daffl closed this as completed Mar 7, 2017
@alexisohayon
Copy link

I have the same problem, I try to make an impersonate strategy and I want to be able to authenticate by "jwt" but never working. It seems that the call feathers.authenticate({strategy: 'jwt', token: accessToken}) is never taking into account the token, using therefore the one from storage.
If I only do a verification of the token, it works and returns the userId of the impersonated user, but with authenticate, it only returns my own accessToken... Any idea?

@alexisohayon
Copy link

@juanchoc did you manage to make it work? @daffl have you ever been is a situation like this one?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants