Update authentication on login
I am not sure about this. but when we get a new access token or refresh token (which I think we do not) we update those. probably does not hurt?
This commit is contained in:
parent
c964c15196
commit
4b0a054596
@ -8,7 +8,12 @@ class User < ApplicationRecord
|
|||||||
user_info = oauth.get_userinfo
|
user_info = oauth.get_userinfo
|
||||||
|
|
||||||
if user = User.find_by(google_id: user_info.id)
|
if user = User.find_by(google_id: user_info.id)
|
||||||
return user, user.authentications.last
|
authentication = user.authentications.last
|
||||||
|
authentication.access_token = auth_client.access_token if auth_client.access_token.present?
|
||||||
|
authentication.refresh_token = auth_client.refresh_token if auth_client.refresh_token.present?
|
||||||
|
authentication.expires_at = Time.at(auth_client.expires_at) if auth_client.expires_at.present?
|
||||||
|
authentication.save
|
||||||
|
return user, authentication
|
||||||
else
|
else
|
||||||
user = User.create(name: user_info.name, email: user_info.email, google_id: user_info.id)
|
user = User.create(name: user_info.name, email: user_info.email, google_id: user_info.id)
|
||||||
authentication = user.authentications.create(
|
authentication = user.authentications.create(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user