-
-
Notifications
You must be signed in to change notification settings - Fork 752
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Feature Request: [authentication-client] event on auth failure #1858
Comments
This is already possible with a short client side error hook: fClient.service('authentication').hooks({
error (context) {
fClient.emit('authFailure', context.error);
}
}); |
Thank you @daffl When using For example,
the catch exception handlers gets invoked, but not the hook for reAuth failure when validating an already stored JWT. That is the main scenario I am trying to handle. When socket reconnections happen the feathers/packages/authentication-client/src/core.ts Lines 70 to 74 in 9fe55b3
|
Ah, indeed, the correct code is fClient.hooks({
error (context) {
const { error } = context;
if (error.code === 401) {
client.emit('authFailure', error);
}
return context;
}
}); This should emit the event on any authentication failure. |
In the authentication-client, when auth attempt is made,
login
andauthenticated
events are generated for theauth success
case:feathers/packages/authentication-client/src/core.ts
Lines 165 to 167 in 9fe55b3
However, there is no event for
auth failure
case. Only the promise is rejected.This feature-request is: please raise an event (something like
authFailure
event) in the failure case, in the catch handler shown below:feathers/packages/authentication-client/src/core.ts
Lines 170 to 172 in 9fe55b3
Such event makes it possible to watch for the
login
andauthFailure
events from anywhere in the app across different services and enable/disable certain functionality. Currently, we are handling success in the event, and failure in thecatch
handler, not so elegant.The text was updated successfully, but these errors were encountered: