tuna42na / baby-namr

Baby Naming Application Frontend
0 stars 1 forks source link

Allow users to create an account, login, and logout #14

Open trvslhlt opened 3 years ago

trvslhlt commented 3 years ago

We want users to have accounts for a number of reasons. First they should be able to save their name selections. Second they should be able to share their selections with others. Before we can offer either of these features we need to introduce accounts to baby-namr. I propose we adapt this rails tutorial for our use case: https://levelup.gitconnected.com/simple-authentication-guide-with-ruby-on-rails-16a6255f0be8

tuna42na commented 3 years ago

After reading the article I'm not sure what I need to do in means of creating things on the frontend. I'm assuming that I need a form that will make a post request to the api and populate a database. Do we just need to decide what the params look like? This feels like I'm not thinking of something.

trvslhlt commented 3 years ago

@tuna42na I'm working on some slides that show how we can adapt the tutorial's approach for react + rails. Will try to share that today.

cwkarwisch commented 3 years ago

This pair of blog posts may be helpful:

https://medium.com/@mazenswar/part-1-creating-a-rails-json-api-using-bcrypt-and-jwt-for-auth-23bfc2217d7b

https://medium.com/@mazenswar/part-2-creating-a-react-frontend-using-react-hooks-react-router-redux-40d195357f66

The first is very similar to what Travis sent, but also includes use of JWT. The second post is all about setting up the React side of things to work with the Rails API.

cwkarwisch commented 3 years ago

Here is the PR for basic authentication on the backend. I generally followed the first of the blog posts I mentioned yesterday, but diverged in a few places where the code in the blog post was broken or did problematic things, like sending the user's password_digest back to the frontend whenever we rendered a JSON representation of the user.

The blog post was still a helpful first start, so hopefully it will be useful on the frontend as well as a good starting place for authentication.