K
K
Kirill Popolov2014-03-31 13:49:24
Ruby on Rails
Kirill Popolov, 2014-03-31 13:49:24

How to implement user authorization?

I understand rails and, accordingly, write an application.
I chose the oauth2 protocol as the authorization method, therefore I store a minimum of information about the user, namely: name, oauth provider identifiers (for example, vk.com user id) and avatar, and service ones, such as user_id and timestamps. If the user is already in my database, a new user is not created, it is immediately redirected to the profile.
How to determine at the backend level whether the user is logged in? I believe that it is necessary to create (or update the default created) a cookie with a session ID in order to determine whether there is a login or not, and also to bind this session to a specific user and pass this data between requests. Here I am, firstly, I'm not sure if I'm right, and secondly, if I'm right, how exactly should this be implemented? The first thing that comes to mind is the storage of user_id and session_id in the database, but with each client request, checking into the database seems like a waste of resources to me.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Arkady Butermanov, 2014-03-31
@ezhikov

If you want your bike, then here is the guide:
www.sitepoint.com/rails-userpassword-authenticatio...
www.sitepoint.com/rails-userpassword-authenticatio...

A
Alexey, 2014-04-01
@fuCtor

Look at Omniauth + a bunch of plugins for different strategies.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question