Commit 0fe942f

mo <mo.khan@gmail.com>
2018-09-09 18:45:59
fix lint errors.
1 parent 54025fc
Changed files (2)
app/controllers/oauths_controller.rb
@@ -22,7 +22,8 @@ class OauthsController < ApplicationController
     response.headers['Cache-Control'] = 'no-store'
     response.headers['Pragma'] = 'no-cache'
     if token_params[:grant_type] == 'authorization_code'
-      @access_token, @refresh_token = Authorization.active.find_by!(code: token_params[:code]).exchange
+      authorization = Authorization.active.find_by!(code: token_params[:code])
+      @access_token, @refresh_token = authorization.exchange
     end
     render formats: :json
   rescue StandardError => error
app/models/authorization.rb
@@ -7,8 +7,8 @@ class Authorization < ApplicationRecord
   has_many :tokens
 
   scope :active, -> { where.not(id: revoked.or(where(id: expired))) }
-  scope :revoked, -> { where('revoked_at < ?', DateTime.now) }
-  scope :expired, -> { where('expired_at < ?', DateTime.now) }
+  scope :revoked, -> { where('revoked_at < ?', Time.now) }
+  scope :expired, -> { where('expired_at < ?', Time.now) }
 
   after_initialize do
     self.expired_at = 10.minutes.from_now unless expired_at.present?