From 91b451180ac132e0567ca4fb0b8ef6c0db68f6a4 Mon Sep 17 00:00:00 2001 From: Tyrel Souza Date: Tue, 15 Apr 2014 13:19:30 -0400 Subject: [PATCH] Change videolistings to be not array until specified in the factory. Add email to authentication --- app/controllers/application_controller.rb | 10 ++++------ spec/factories/videolistings.rb | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index dc0c31a..8265b5e 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -5,17 +5,15 @@ class ApplicationController < ActionController::Base before_action :authenticate_user_from_token! before_action :authenticate_user! #unless Rails.env.test? - private def authenticate_user_from_token! - user_token = params[:user_token].presence - user = user_token && User.find_by_authentication_token(user_token.to_s) + user_email = params[:user_email].presence + user = user_email && User.find_by_email(user_email) - if user - sign_in user, store: false + if user && Devise.secure_compare(user.authentication_token, params[:user_token]) + sign_in user, store:false end - end diff --git a/spec/factories/videolistings.rb b/spec/factories/videolistings.rb index 42a2c9a..5a8fd68 100644 --- a/spec/factories/videolistings.rb +++ b/spec/factories/videolistings.rb @@ -11,6 +11,6 @@ FactoryGirl.define do keywords "MyString" focus "MyString" notes "MyString" - asseturls ["MyString", "MyString2"] + asseturls "MyString, MyString2" end end