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

Bundled feathers.js - Socket Authentication with Local Strategy Always Times Out #155

Closed
robotlandman opened this issue Mar 21, 2017 · 2 comments

Comments

@robotlandman
Copy link

Steps to reproduce

Client-side Gist: https://gist.github.com/robotlandman/4e7feb3ec15a964250ab2941dc8cc7bb

I'm using the unified feathers-client from here:
https://github.com/feathersjs/feathers-client/blob/master/dist/feathers.js

Expected behavior

client.authenticate() should redirect to the successful login page as specified in my login.js file or display an error if authentication is unsuccessful.

Actual behavior

The feathers-client socket timeout handler is hit in both cases - on successful authentication and user not found. The response is always: "Error: Authentication timed out" after the default 5 seconds.

I see the server reply on the socket right away (in the code I'm listening for 'authenticated' and 'unauthorized' socket events for testing) with the correct response, including the token when authentication is successful. The feathers-client ignores these responses and doesn't store the token in localStorage on successful authentication.

Here are the web browser console outputs for the socket events to confirm the authentication is happening as expected on feathers server-side:
Successful authentication
Socket authenticated: {"token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJfaWQiOiJiNFBRTllDNkZlMjlhN1ZLIiwiaWF0IjoxNDkwMTAxOTIyLCJleHAiOjE0OTAxODgzMjIsImlzcyI6ImZlYXRoZXJzIn0.Uys3gyHUDV_78B0JRzcqmOYvzbqyJ9lPd7e1JlbggMI","data":{"email":"admin@local","roles":["admins"],"_id":"b4PQNYC6Fe29a7VK"}}

User not found
Socket unauthorized: {"name":"NotAuthenticated","message":"Invalid login.","code":401,"className":"not-authenticated","errors":{}}

System configuration

Tell us about the applicable parts of your setup.

Module versions (especially the part that's not working):
Server-Side
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]

Client-Side
Whatever is bundled in the latest feathers-client/dist/feathers.js file - not sure how you tell the version?

NodeJS version:
v6.10.0

Operating System:
Server: Ubuntu 16.04
Client: Windows 10

Browser Version:
Chrome 56.0.2924.87
Firefox 52.0.1

React Native Version:
N/A

Module Loader:
N/A

@daffl
Copy link
Member

daffl commented Mar 21, 2017

You should not link to the master dist but to a specific version (which is what we are showing in the documentation). The current master requires feathers-authentication 1.0.0 on the server (and linking to it directly will break your app in the future).

As shown in the client documentation you can link to the latest backwards compatible 1.x version of this package using Unpkg like this:

<script type="text/javascript" src="//unpkg.com/feathers-client@^1.0.0/dist/feathers.js"></script>

@robotlandman
Copy link
Author

I figured I was doing something wrong. That was it - thanks!

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