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]
|
email = token.split[1].split("=")[1]
|
||||||
token = token.split[0]
|
token = token.split[0]
|
||||||
user_email = email.presence
|
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
|
end
|
||||||
else
|
else
|
||||||
user_email = params[:user_email].presence
|
user_email = params[:user_email].presence
|
||||||
token = params[:user_token]
|
token = params[:user_token]
|
||||||
user = user_email && User.find_by_email(user_email)
|
end
|
||||||
if user && Devise.secure_compare(user.authentication_token, token)
|
|
||||||
sign_in user, store:false
|
log_it_in(token, user_email)
|
||||||
end
|
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
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user