Commit 54025fc

mo <mo.khan@gmail.com>
2018-09-09 18:44:05
fix linter errors.
1 parent f9f1a74
app/models/authorization.rb
@@ -6,9 +6,9 @@ class Authorization < ApplicationRecord
   belongs_to :client
   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 :active, -> { where.not(id: revoked.or(where(id: expired))) }
+  scope :revoked, -> { where('revoked_at < ?', DateTime.now) }
+  scope :expired, -> { where('expired_at < ?', DateTime.now) }
 
   after_initialize do
     self.expired_at = 10.minutes.from_now unless expired_at.present?
app/models/token.rb
@@ -1,16 +1,18 @@
+# frozen_string_literal: true
+
 class Token < ApplicationRecord
   enum token_type: { access: 0, refresh: 1 }
   belongs_to :authorization
   belongs_to :subject, polymorphic: true
   belongs_to :audience, polymorphic: true
 
-  scope :expired, ->{ where('expired_at < ?', Time.now) }
-  scope :revoked, ->{ where('revoked_at < ?', Time.now) }
+  scope :expired, -> { where('expired_at < ?', Time.now) }
+  scope :revoked, -> { where('revoked_at < ?', Time.now) }
 
   after_initialize do |x|
     x.uuid = SecureRandom.uuid if x.uuid.nil?
     if x.expired_at.nil?
-      x.expired_at = access? ? 1.hour.from_now  : 1.day.from_now
+      x.expired_at = access? ? 1.hour.from_now : 1.day.from_now
     end
   end
 
app/views/oauths/bad_request.json.jbuilder
@@ -1,1 +1,3 @@
+# frozen_string_literal: true
+
 json.error t('.invalid_request')
app/views/oauths/token.json.jbuilder
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
 json.access_token @access_token.to_jwt
 json.token_type 'Bearer'
 json.expires_in 1.hour.to_i
db/migrate/20180909173139_create_tokens.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
 class CreateTokens < ActiveRecord::Migration[5.2]
   def change
     create_table :tokens do |t|