This is prepared Rails authentication template, part of `React-Rails authentication`, Rails back-end and logic are built and ready to use.
Screenshots of the app.Note: This is a demo of this project combined with React-front.
http//localhost:3000/users/sign_in
- Route ==> Sign in
- Method ==> POST
- Body ==>
{ "user": { "email": "[email protected]", "password": "12345678" } }
- Response token ==> data.headers.authorization
http//localhost:3000/users
- Route ==> Sign up
- Method ==> POST
- Body ==>
{ "user": { "email": "[email protected]", "password": "12345678" } }
- Response token ==> data.headers.authorization
http//localhost:3000/member
- Route ==> To know if user logged in?
- Method ==> GET
- headers ==>
token: token you saved from log in or sign up user
- Response ==> data.data.message=> 'yeppa you did it.'
http//localhost:3000/users/sign_out
- Route ==> To log out
- Method ==> DELETE
- headers ==>
token: token you saved from log in or sign up user
- Response ==> data.data.message=> 'You are logged out.'
-
Rails-Api
-
Devise
-
Devise-jwt
- Ruby 3
- Rails 6
To get this project set up on your local machine, follow these simple steps:
Step 1
In order to use this project all you have to to is follow these simple steps :
-
Clone the Rails repo and cd inside the project.
-
Run
Rake secret
, this will generate a secret key, hold it for the next step. -
Create a
.env
file in the root of the project and inside it put thisDEVISE_JWT_SECRET_KEY = < your secret key from previuos step >
-
Inside
config/initializers/cors.rb
if you it locally you dont need to do this but if you want to use it from specific domain you should change line 12 fromorigins '*'
toorigins 'Your domain here'
. -
Note: If you publish this website and upload it to heroku, do not forget to add a
Config variable
to your app in heroku, simply go to heroku, go to your app, click on setting, click on config vars then put yourDEVISE_JWT_SECRET_KEY
then your secret key.
give a ⭐️ if you like this project!
This project is MIT