Quantcast
Channel: Active questions tagged redis+ruby-on-rails - Stack Overflow
Viewing all articles
Browse latest Browse all 873

Devise without User table, but Redis instead

$
0
0

I have been looking around for a while now, but can't find a solution that fits my needs or an example that can help me on my way...

TL;DR

How can I make use of Devise+Redis without needing a User table & Object, but instead store user/session related data (obtained from API-call e.g. email, access_token, refresh_token, admin_boolean) in Redis for the length of the session?

The problem

I have an API (rails +doorkeeper+grape) that is used by a rails client. Following the concept of eating my own dog food this client makes calls to the API to obtain all the relevant info, data etc. and show or (process if necessary, but mainly done in API) this in the client.

Since my client almost totally depends on the API I do not have any tables on the client side, except for one User table, which I want to get rid of.

This User table exists because I currently make use of Devise to allow (new) users to register themselves and log in into my client app. With a few modifications in the session_controller, I have been able to send the registration data to the API, where the data is saved. Then when the User logs in a call is made to the API/Doorkeeper using the Oauth2 gem to obtain an access_token + refresh_token (+ email + admin_boolean) that can be used for sending all further requests.

Currently this data is saved as attributes as part of an User object that is used throughout my application, ie every time a user logs in I call User.new(data_params).

However I much rather get rid of this approach and instead save all the data in Redis, allowing me to drop the User table and the client db...

My problem is not that I don't know how to save the values in Redis, but rather that I can't figure out how to use Devise without the User table, since Devise/Warden requires a resource object.

So my question is: Does anyone know how I can tackle this problem? Also what would be possible limitations of this approach? (I don't need the functionality of a relational db)

Please let me know if anything is unclear (it has been a long day ;-) thanks for any help of suggestions in advance!


Viewing all articles
Browse latest Browse all 873

Trending Articles