Ask A Question

Notifications

You’re not receiving notifications from this thread.

2 rails apps , 1 database

AgonIdrizi asked in Rails

Hi fellas,
I have a project to do where 2 apps share one database!
1. The first one (app1) is a basic blogging application that lets a user register and then write posts. Each user can write, read, update, list and destroy its own posts (including texts, images or whatever);
2. app1: the user is able to filter posts by their description;

3. app1: exposes the user authentication via an API;
4. The second app (app2) shares the login w/ the first app, via the a forementioned API (that is, an user A registered to app1 can also log into app2; user data remains in app1’s DB).

5. app2 just shows posts by any registered user to logged in users.

My question is how i can approach steps 3,4,5!

My idea so far is:
I will try to have app-1 authentication with devise and also make api/v1 version to app1, so then app-2 can login to api/v1 with JWT and request resources from api/v1
In app-2 im thinking to have a users-controller, and inside a login method which will accept email,pasword params from a form, then i will make a curl request to api/v1/auth/log and based on that i will login the user in app-2!

But i have doubts, how i will request resources from app-1. Do i need to send token in headers with every request and then based on header token, app-1 will authorize app-2-requests!?

I'm relatively new to rails, sorry for my dumb question. I would do app-2 to be a front-end React/Vue, but they said also app-2 need to be rails-app!

Thank You,
Agon.

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 81,842+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more.

    © 2024 GoRails, LLC. All rights reserved.