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

Feathers client hooks don't run when calling 'authenticate' unless socket has connected #586

Closed
FossPrime opened this issue Oct 19, 2017 · 5 comments

Comments

@FossPrime
Copy link

FossPrime commented Oct 19, 2017

Steps to reproduce

  • start with feathers-chat example, included vanilla version works
  • set up a feathers client with const socket = io('http://google.com:6666');
  • set up a before auth hook client.hooks({ before (hook) { console.log(hook) } })
  • npm start the app, hard refresh browser and try to log in

This file has the final app.js. there is no way to create a user with it, but the issue will manifest without connecting to the socket server... any valid looking email and password will work
https://gitlab.com/snippets/1680348

Expected behavior

auth.authenticate should trip the before hook and log to the console... whether or not the websocket server is alive or has been alive should be irrelevant.

Actual behavior

auth.authenticate does not trip the before hook

System configuration

Module versions:
Default feathers-examples-chat
"feathers-authentication": "^1.2.6",
NodeJS version: 8.7.0
Operating System: MacOS Sierra
Browser Version: Chrome 62

@daffl
Copy link
Member

daffl commented Oct 19, 2017

What exactly are you expecting? A client side before hook will always run since it executes before the server request is being made.

@FossPrime
Copy link
Author

FossPrime commented Oct 19, 2017

@daffl yes it should always run... but it doesn't run when you call authenticate if

  • A socket is configured
  • the socket has never connected

I stumbled on this while trying to throw on before.all if I knew for a fact that we had no connection. saving up to 5 seconds of waiting around for promises to reject. This method works for everything but the feathersClient.authenticate(...) service.

@daffl
Copy link
Member

daffl commented Oct 19, 2017

Currently socket authentication uses a custom authenticate event, not the authentication service directly (it is called on the server but the client won't know about that).

There was reasons for it but it turned out that it was a bad decision that will hopefully be fixed in the next version of feathers-authentication.

@FossPrime FossPrime changed the title Authenticate hooks don't run unless socket has connected Feathers client hooks don't run when calling 'authenticate' unless socket has connected Oct 19, 2017
@ekryski ekryski added this to the 2.0 milestone Oct 23, 2017
@daffl daffl removed this from the 2.0 milestone Jan 20, 2018
@huytran0605
Copy link

My client app is using socket io to connect with server.
Calling app.authenticate() is not trigger after hook function.
but other services for e.g app.service('users') still can be trigger hook function.

@daffl
Copy link
Member

daffl commented May 8, 2019

This has been done in Feathers v4 authentication. The new authentication-client is calling the service methods directly and allows to register hooks.

Please see the migration guide for more information. Closing this issue in order to archive this repository. Related issues can be opened at the new code location in the Feathers main repository.

@daffl daffl closed this as completed May 8, 2019
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