From 051324e12a7384b15aaa68f53dd43ad0b3c67812 Mon Sep 17 00:00:00 2001
From: Timothy Andrew <mail@timothyandrew.net>
Date: Tue, 19 Apr 2016 16:24:33 +0530
Subject: [PATCH] Refactor `authenticate_user_from_private_token!`

- No need to use `if`s when we have a `presence` check already.
---
 app/controllers/application_controller.rb | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 590f9383f7f..2b2726c048c 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -67,13 +67,7 @@ class ApplicationController < ActionController::Base
   # From https://github.com/plataformatec/devise/wiki/How-To:-Simple-Token-Authentication-Example
   # https://gist.github.com/josevalim/fb706b1e933ef01e4fb6
   def authenticate_user_from_private_token!
-    user_token = if params[:authenticity_token].presence
-                   params[:authenticity_token].presence
-                 elsif params[:private_token].presence
-                   params[:private_token].presence
-                 elsif request.headers['PRIVATE-TOKEN'].present?
-                   request.headers['PRIVATE-TOKEN']
-                 end
+    user_token = params[:authenticity_token].presence || params[:private_token].presence  || request.headers['PRIVATE-TOKEN'].presence
     user = user_token && User.find_by_authentication_token(user_token.to_s)
 
     if user
-- 
GitLab