testing
This commit is contained in:
parent
177f9e6982
commit
e56cad5e3a
@ -18,27 +18,25 @@ class ApplicationController < ActionController::Base
|
||||
|
||||
|
||||
private
|
||||
|
||||
|
||||
def authenticate_user_from_token!
|
||||
if request.headers["HTTP_AUTHORIZATION"]
|
||||
authenticate_or_request_with_http_token do |token, options|
|
||||
email = token.split[1].split("=")[1]
|
||||
token = token.split[0]
|
||||
user_email = email.presence
|
||||
def authenticate_user_from_token!
|
||||
if request.headers["HTTP_AUTHORIZATION"]
|
||||
authenticate_or_request_with_http_token do |token, options|
|
||||
email = token.split[1].split("=")[1]
|
||||
token = token.split[0]
|
||||
user_email = email.presence
|
||||
end
|
||||
else
|
||||
user_email = params[:user_email].presence
|
||||
token = params[:user_token]
|
||||
end
|
||||
else
|
||||
user_email = params[:user_email].presence
|
||||
token = params[:user_token]
|
||||
|
||||
log_it_in(token, user_email)
|
||||
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
|
||||
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
|
||||
|
9
spec/controllers/application_controller_spec.rb
Normal file
9
spec/controllers/application_controller_spec.rb
Normal file
@ -0,0 +1,9 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe ApplicationController do
|
||||
|
||||
it "can fail login" do
|
||||
get "root#index"
|
||||
end
|
||||
|
||||
end
|
Loading…
Reference in New Issue
Block a user