refactoring authentication
This commit is contained in:
parent
f3e58009ef
commit
177f9e6982
@ -26,19 +26,19 @@ class ApplicationController < ActionController::Base
|
||||
email = token.split[1].split("=")[1]
|
||||
token = token.split[0]
|
||||
user_email = email.presence
|
||||
|
||||
user = user_email && User.find_by_email(user_email)
|
||||
if user && Devise.secure_compare(user.authentication_token, token)
|
||||
sign_in user, store:false
|
||||
end
|
||||
end
|
||||
else
|
||||
user_email = params[:user_email].presence
|
||||
token = params[:user_token]
|
||||
user = user_email && User.find_by_email(user_email)
|
||||
if user && Devise.secure_compare(user.authentication_token, token)
|
||||
sign_in user, store:false
|
||||
end
|
||||
end
|
||||
|
||||
log_it_in(token, user_email)
|
||||
end
|
||||
|
||||
def log_it_in(token, user_email)
|
||||
user = user_email && User.find_by_email(user_email)
|
||||
if user && Devise.secure_compare(user.authentication_token, token)
|
||||
sign_in user, store: false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user