This project demonstrate the use of session
and JWT
authentication in the same app.
For the JWT
authentication supports two mechanisms REST
and GraphQL
Clone the project and install the dependencies
git clone git@github.com:warborn/hybrid-app.git
cd hybrid-app
bundle install
yarn install
Prepare the database and start the server
rails db:setup
rails s
You can view the app live here
You can create a new account here
The project supports authentication via GraphQL, you can use the following queries:
mutation LOGIN {
login(email: "user@app.com", password: "password") {
email
id
token
}
}
mutation {
logout
}
query {
me {
id
email
}
}
GraphQL is mounted in the route /api/graphql
Note: The logout
mutation and me
query are protected by the authentication mechanism, in order to run them properly, an authorization header with a valid token should be sent along with the request.
Authorization: Bearer {VALID_TOKEN}
The project supports authentication via a REST API
[POST] -> /api/login
{
"api_user": {
"email": "root@app.com",
"password": "password"
}
}
[DELETE] -> /api/logout
[GET] -> /api/users/me
Note: The /api/logout
/api/users/me
endpoints are protected by the authentication mechanism, in order to run them properly, an authorization header with a valid token should be sent along with the request.