Git Product home page Git Product logo

json_authentication_with_devise_rails_demo's Introduction

README

๐Ÿ“– Table of Contents

Table of Contents
  1. About The Project
  2. Getting Started
  3. Testing authentication
  4. Credits

๐Ÿ“ About The Project

Not a while ago, I started a side project to improve my engineering skills. I decided to make a web application with Rails + React stack. When it came to the authentication implementation, I went with the devise gem.

Devise is a powerful and customizable authentication library used for Rails applications. It comes with controllers, views and there are a few commands you need to run to make the authorization work.

However, my application had a different frontend framework (React) that handled the views and was supposed to make API calls to the Rails server to authenticate a user.

It took some research till finding a way to make the devise work with my configuration or, in other words, to make it accept and respond with JSON.

I learned a lot along the way, and I summarised my thoughts in an article. While researching, I got a suggestion to read an article from a blog that solved 99% of the devise configuration problem. There were comments under the article asking the author for a demo application. Unfortunately, it seems like author removed the article as I haven't found THE article which helped me :(

So, I decided to make a demo application myself, hoping that it would help people who are looking for a solution to the same configuration problems.

If you need a detailed explanation of the whole process, you can check out this article.

This application is for devise JSON API authentication demo purpose only. It has only a User model and devise gem installed and set up to work with JSON.

๐Ÿ“– Getting Started

Install all gems bundle install

Create database rails db:create

Migrate database rails db:migrate

Start the app rails s

๐Ÿ“– Testing authentication

Check the endpoints rails routes --expanded to view all endpoints.
Don't forget to add { Accept: application/json } header to the request, or you won't see the JSON response โ—

User sign up

URL: /api/v1/users
Method: POST
Body (JSON): {
    user: {
        email: [email protected],
        password: 123456,
        password_confirmation: 123456
    }
}

User sign in

URL: /api/v1/users/sign_in
Method: POST
Body (JSON): {
    user: {
        email: [email protected],
        password: 123456
    }
}

๐Ÿ“œ Credits

MiniEngineer

Hashnode Badge GitHub Badge LinkedIn Badge

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.