refactoring authentication

This commit is contained in:
Tyrel Souza 2014-04-25 11:43:18 -04:00
parent f3e58009ef
commit 177f9e6982

View File

@ -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]
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
end