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

Devise like authentication #5

Open
tibastral opened this issue Aug 24, 2016 · 1 comment
Open

Devise like authentication #5

tibastral opened this issue Aug 24, 2016 · 1 comment

Comments

@tibastral
Copy link

Hello !

I have a use case :

I need to have a authentication like rails+devise but handled directly by Elm.

How would you do that without cookies ?

@mltsy
Copy link

mltsy commented Feb 9, 2017

Elm doesn't prevent you from using cookies. If your server sets a cookie in the response header, the browser will include that cookie in future requests for that domain until the cookie expires. So you can still have a server endpoint where you submit a username and password to authenticate a user, that responds with a cookie header to login the user within the current browser/user-agent. Elm doesn't have to know anything about that. It's all handled by the user-agent.

In order to notify your Elm app that the user was successfully logged in, you could either use appropriate HTTP statuses, and check those in your elm app (i.e. if the response code is 200, the user is logged in, if it's anything else, it failed) or return some JSON value, and read that to tell whether the user is logged in and/or what their ID is, etc.

Does that answer the question, or am I missing the focus?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants