Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example app #386

Closed
jiangts opened this Issue Dec 27, 2016 · 9 comments

Comments

Projects
None yet
4 participants
@jiangts
Copy link

jiangts commented Dec 27, 2016

I'm trying to migrate to feathers-authentication 1.0.x and followed the migration guide. However, it wasn't clear how to re-write the login page. I tried posting to /authentication but it returned the a json with

{ accessToken: "SOME_TOKEN" }

Any tips on how to do this, and on setting redirects in general?

@marshallswain

This comment has been minimized.

Copy link
Member

marshallswain commented Dec 27, 2016

@jiangts /authentication is a regular Feathers service, so to get redirects, you'll need to create a separate Express middleware that calls app.authenticate() internally to get a token, then redirects and sends whatever you want back to the user.

@jiangts

This comment has been minimized.

Copy link
Author

jiangts commented Dec 28, 2016

Maybe I'm missing some functionality in Express, but how do I redirect the client to say, /app/ AND send a token back to the client? (sure, I can put it in a query param but this doesn't sound like the best idea security wise).

Also, will this be smoothly integrated into feathers-client-authentication as it was previously? (or maybe it was just integrated into the feathers-cli scaffold). I remember it magically kind of just worked when I posted to /auth/local before :).

@marshallswain

This comment has been minimized.

Copy link
Member

marshallswain commented Dec 28, 2016

What's the exact workflow you want to happen? You authenticate with an Ajax request then handle the response on the client? Or you want to post to a page and have a full redirect and page load? There are a few ways to handle it. The Ajax request works the most seamlessly with the feathers client.

@jiangts

This comment has been minimized.

Copy link
Author

jiangts commented Dec 28, 2016

Aha, I think I might've been confused by the experience on feathers 0.7.x and feathers-client. In the feathers scaffold, /login.html doesn't include feathers-client yet /app/index.html just calls app.authenticate().then(showViewFn) and a JWT magically appeared in my localStorage.

It seems that the login.html page now needs to include feathers-client and do a client side redirect to /app/ to get the same experience. Does that sound right?

@marshallswain

This comment has been minimized.

Copy link
Member

marshallswain commented Dec 28, 2016

You can definitely redirect if you prefer to do it. Using Single Page App-style page routing will make it so you don't have to call app.authenticate() again when the next page loads. Socket auth is stateful on the server. Since doing a full redirect, whether on the client on the server, will disconnect the socket, you would have to call app.authenticate() to have an authenticated socket again.

@ekryski

This comment has been minimized.

Copy link
Member

ekryski commented Dec 30, 2016

Dammit. I'll get those docs up to date by Monday for sho!

@jiangts

This comment has been minimized.

Copy link
Author

jiangts commented Dec 31, 2016

Thanks so much! Shall I leave this open and you can close it when the docs are updated?

@tjme

This comment has been minimized.

Copy link

tjme commented Dec 31, 2016

Similarly, is there any chance that feathers-chat will be updated in line with 1.0, as that might help clarify?

@marshallswain

This comment has been minimized.

Copy link
Member

marshallswain commented Mar 31, 2017

This is now implemented in the feathers-chat repo, auk branch. The client examples will be updated one at a time. The Feathers Vuex Chat example is already finished here: http://github.com/feathersjs/feathers-chat-vuex

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.