Code Monkey home page Code Monkey logo

rails-auth-app's Introduction

README

A simple AuthApp using Rails 7(API only).

Features

  1. User sign up and login
  2. Generate & verify OTP
  3. Update password & toggle 2FA

Rails version - 7.0.4
Ruby version - 3.0.2

Installation & Setup:

Clone the project.
Create master.key file in config folder (value - 88b37458d4861b547e93a24e4c173387)
Run bundle install and rails db:setup.
Start the Rails server using rails s.
Run the RSpec tests with rspec spec/.

App Workflow:

Register using email id & password (the password should be strong).
Click on the confirmation email link to verify the account.
Log in to create a temporary JWT and use that token for generating and verifying OTP.
Generate & verify the OTP (requires the temporary JWT token).
Once the OTP is verified, use the JWT token for authenticating other actions.
Enabling or disabling 2FA  requires the current password + the newly generated OTP.
Updating the password requires the current password + the newly generated OTP.
Note - OTP will be send through the registered email id

Code coverage file:///{path}/coverage/index.html

APIPIE documentation http://localhost:3000/apipie

CURL Requests

  1. Registration
    curl --location 'localhost:3000/users/signup' \
    --header 'Content-Type: application/json' \
    --data-raw '{ "email": "[email protected]", "password": "Test@1234", "password_confirmation": "Test@1234"}'
    
    
  2. Confirm Email
    curl --location 'http://localhost:3000/users/confirmations/AccNSNPWb1tQcJcyenlIHA'
    
  3. Resend Confirmation Email
    curl --location 'localhost:3000/users/confirmations' \
    --header 'Content-Type: application/json' \
    --data-raw '{"email": "[email protected]", "password": "Test@1234"}'
    
  4. Login
    curl --location 'localhost:3000//users/login' \
    --header 'Content-Type: application/json' \
    --data-raw '{"email": "[email protected]", "password": "Test@1234"}'
    
    
  5. Generate OTP
    curl --location --request POST 'localhost:3000/users/generate_otp' \
    --header 'Content-Type: application/json' \
    --header 'Accept: application/json' \
    --header 'Authorization: Bearer Token' \
    --data ''
    
  6. Verify OTP
    curl --location 'localhost:3000/users/verify_otp' \
    --header 'Content-Type: application/json' \
    --header 'Accept: application/json' \
    --header 'Authorization: Bearer Token' \
    --data '{"otp": "388409"}'
    
  7. Toggle 2FA
    curl --location --request PATCH 'localhost:3000/users/toggle_2fa' \
    --header 'Content-Type: application/json' \
    --header 'Accept: application/json' \
    --header 'Authorization: Bearer Token' \
    --data-raw '{"password": "Test@1234", "otp": "544608", "enable_2fa": false}'
    
  8. Update Password
    curl --location --request PATCH 'localhost:3000/users/passwords' \
    --header 'Content-Type: application/json' \
    --header 'Accept: application/json' \
    --header 'Authorization: Bearer Token' \
    --data-raw '{"current_password": "Test@1234", "new_password": "TestNew@1234", "otp": "275073"}'

rails-auth-app's People

Watchers

RAJIL KV avatar

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.