Skip to content
This repository has been archived by the owner on Mar 22, 2022. It is now read-only.

How can I verify a user by local strategy on client without real authentication? #704

Closed
flight9 opened this issue Sep 26, 2018 · 5 comments

Comments

@flight9
Copy link

flight9 commented Sep 26, 2018

How can I verify a user by username/password(like local strategy) on client without call authenticate() to really login?

@daffl
Copy link
Member

daffl commented Sep 26, 2018

If I understand correctly, that is not possible. Only the server knows the actual hashed password to compare the credentials against. You could call app.service('authentication').create({ strategy: 'local', email, password }) which will not authenticate your application (but return an access token).

@flight9
Copy link
Author

flight9 commented Sep 26, 2018

@daffl I'm using vuex on client and I can't get service('authentication') directly, I tried this:

...mapActions('authentication', {createAuthentication: 'create'}),

but failed with error: [vuex] module namespace not found in mapActions(): authentication/

@flight9
Copy link
Author

flight9 commented Sep 26, 2018

I found in feathers-vuex a feathersClient which can help me get service on client:

import feathersClient from '@/api/feathers-client'

const authService = feathersClient.service('/authentication')
  let res = await authService.create({
    strategy: 'local',
    email,
    password
  })

@daffl But then another question is even if I pass in a wrong email or password, the create() will always return an accessToken, that can't help me verify an invalid user.

Is the state that I'm logining as user A, and use the code above to verify user B, affect the result of create()?

@flight9
Copy link
Author

flight9 commented Sep 26, 2018

I have to logout first, then use service('authentication').create() or auth/authenticate() to verify or authenticate a user.

@daffl thanks for your reply.

Though I find a way to bypass the limit, I think there still maybe some scenarios when a logined user need to verify whether another account is a valid account.

@daffl
Copy link
Member

daffl commented Sep 26, 2018

Yes. This is a known issue and tracked in feathersjs/feathers#1017. Closing this one since this repository will be moved.

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

2 participants