diff --git a/Gemfile b/Gemfile index e83c1f3ec..67ecc076a 100644 --- a/Gemfile +++ b/Gemfile @@ -26,11 +26,17 @@ end gem 'autoprefixer-rails', '>=5.2' +gem 'oauth2' +gem 'doorkeeper' + gem 'omniauth' -gem 'omniauth-twitter' +gem 'omniauth-oauth2' gem 'omniauth-facebook' -gem 'omniauth-linkedin' +gem 'omniauth-github' +gem 'omniauth-gitlab' gem 'omniauth-google-oauth2' +gem 'omniauth-linkedin-oauth2' +gem 'omniauth-twitter' gem 'twitter' gem 'koala' diff --git a/Gemfile.lock b/Gemfile.lock index f2b500429..72c054fd0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -56,7 +56,7 @@ GEM childprocess (0.5.9) ffi (~> 1.0, >= 1.0.11) clavius (1.0.2) - clearbit (0.2.3) + clearbit (0.2.4) nestful (~> 1.1.0) coderay (1.1.1) coffee-rails (4.2.1) @@ -82,6 +82,8 @@ GEM docile (1.1.5) domain_name (0.5.20160615) unf (>= 0.0.5, < 1.0.0) + doorkeeper (4.0.0) + railties (>= 4.2) eco (1.0.0) coffee-script eco-source @@ -100,7 +102,7 @@ GEM multipart-post (>= 1.2, < 3) ffi (1.9.14) formatador (0.2.5) - globalid (0.3.6) + globalid (0.3.7) activesupport (>= 4.1.0) guard (2.14.0) formatador (>= 0.2.4) @@ -181,13 +183,20 @@ GEM rack (>= 1.0, < 3) omniauth-facebook (3.0.0) omniauth-oauth2 (~> 1.2) + omniauth-github (1.1.2) + omniauth (~> 1.0) + omniauth-oauth2 (~> 1.1) + omniauth-gitlab (1.0.2) + omniauth (~> 1.0) + omniauth-oauth2 (~> 1.0) omniauth-google-oauth2 (0.4.1) jwt (~> 1.5.2) multi_json (~> 1.3) omniauth (>= 1.1.1) omniauth-oauth2 (>= 1.3.1) - omniauth-linkedin (0.2.0) - omniauth-oauth (~> 1.0) + omniauth-linkedin-oauth2 (0.1.5) + omniauth (~> 1.0) + omniauth-oauth2 omniauth-oauth (1.1.0) oauth omniauth (~> 1.0) @@ -200,7 +209,7 @@ GEM parser (2.3.1.2) ast (~> 2.2) pg (0.18.4) - phony (2.15.26) + phony (2.15.27) pkg-config (1.1.7) pluginator (1.3.0) power_assert (0.3.0) @@ -211,7 +220,7 @@ GEM coderay (~> 1.1.0) method_source (~> 0.8.1) slop (~> 3.4) - puma (3.4.0) + puma (3.6.0) rack (1.6.4) rack-livereload (0.3.16) rack @@ -249,7 +258,7 @@ GEM rb-inotify (0.9.7) ffi (>= 0.5.0) ref (2.0.0) - rubocop (0.41.2) + rubocop (0.42.0) parser (>= 2.3.1.1, < 3.0) powerpack (~> 0.1) rainbow (>= 1.99.1, < 3.0) @@ -259,7 +268,7 @@ GEM ruby_dep (1.3.1) rubyzip (1.2.0) sass (3.4.22) - sass-rails (5.0.5) + sass-rails (5.0.6) railties (>= 4.0.0, < 6) sass (~> 3.1) sprockets (>= 2.8, < 4.0) @@ -283,7 +292,7 @@ GEM slack-notifier (1.5.1) slop (3.6.0) spring (1.7.2) - sprockets (3.6.3) + sprockets (3.7.0) concurrent-ruby (~> 1.0) rack (> 1, < 3) sprockets-rails (3.1.1) @@ -291,7 +300,7 @@ GEM activesupport (>= 4.0) sprockets (>= 3.0.0) sqlite3 (1.3.11) - test-unit (3.2.0) + test-unit (3.2.1) power_assert therubyracer (0.12.2) libv8 (~> 3.16.14.0) @@ -343,6 +352,7 @@ DEPENDENCIES daemons delayed_job_active_record diffy + doorkeeper eco em-websocket email_verifier @@ -359,10 +369,14 @@ DEPENDENCIES mime-types mysql2 (~> 0.3.20) net-ldap + oauth2 omniauth omniauth-facebook + omniauth-github + omniauth-gitlab omniauth-google-oauth2 - omniauth-linkedin + omniauth-linkedin-oauth2 + omniauth-oauth2 omniauth-twitter pg phony diff --git a/app/controllers/first_steps_controller.rb b/app/controllers/first_steps_controller.rb index dbfd536fd..ed81a24a3 100644 --- a/app/controllers/first_steps_controller.rb +++ b/app/controllers/first_steps_controller.rb @@ -242,7 +242,7 @@ class FirstStepsController < ApplicationController if !test_customer test_ticket_active = false end - if Group.where(active: true, name: 'Users').count == 0 + if Group.where(active: true, name: 'Users').count.zero? test_ticket_active = false end return result if test_ticket_active diff --git a/app/models/application_model.rb b/app/models/application_model.rb index 178371e41..a6951d4f6 100644 --- a/app/models/application_model.rb +++ b/app/models/application_model.rb @@ -1346,7 +1346,7 @@ store attachments for this object self.attachments_buffer = attachments # update if object already exists - return if !(id && id != 0) + return if !(id && id.nonzero?) attachments_buffer_check end diff --git a/app/models/email_address.rb b/app/models/email_address.rb index 7783ec819..c3d86ab88 100644 --- a/app/models/email_address.rb +++ b/app/models/email_address.rb @@ -67,7 +67,7 @@ check and if channel not exists reset configured channels for email addresses def update_email_address_id not_configured = Group.where(email_address_id: nil).count total = Group.count - return if not_configured == 0 + return if not_configured.zero? return if total != 1 group = Group.find_by(email_address_id: nil) group.email_address_id = id diff --git a/app/models/job.rb b/app/models/job.rb index dff007a82..c9a34da89 100644 --- a/app/models/job.rb +++ b/app/models/job.rb @@ -129,7 +129,7 @@ class Job < ApplicationModel # loop week days (0..7).each do |day_counter| time_to_check = nil - day_to_check = if day_counter == 0 + day_to_check = if day_counter.zero? time else time + 1.day @@ -163,10 +163,10 @@ class Job < ApplicationModel day_to_check = day_to_check - day_to_check.sec.seconds # loop minutes till next full hour - if day_to_check.min != 0 + if day_to_check.min.nonzero? (0..5).each do |minute_counter| - if minute_counter != 0 - break if day_to_check.min == 0 + if minute_counter.nonzero? + break if day_to_check.min.zero? day_to_check = day_to_check + 10.minutes end next if !timeplan['hours'][day_to_check.hour] && !timeplan['hours'][day_to_check.hour.to_s] diff --git a/app/models/object_manager/attribute.rb b/app/models/object_manager/attribute.rb index bd8c5b6d5..a003a41b3 100644 --- a/app/models/object_manager/attribute.rb +++ b/app/models/object_manager/attribute.rb @@ -631,7 +631,7 @@ to send no browser reload event, pass false # sent maintenance message to clients if send_event - if execute_db_count != 0 + if execute_db_count.nonzero? if ENV['APP_RESTART_CMD'] AppVersion.set(true, 'restart_auto') sleep 4 @@ -639,7 +639,7 @@ to send no browser reload event, pass false else AppVersion.set(true, 'restart_manual') end - elsif execute_config_count != 0 + elsif execute_config_count.nonzero? AppVersion.set(true, 'config_changed') end end diff --git a/app/models/scheduler.rb b/app/models/scheduler.rb index 1277842a6..1f44b2257 100644 --- a/app/models/scheduler.rb +++ b/app/models/scheduler.rb @@ -122,10 +122,10 @@ class Scheduler < ApplicationModel UserInfo.current_user_id = nil loop do success, failure = Delayed::Worker.new.work_off - if failure != 0 + if failure.nonzero? raise "ERROR: #{failure} failed background jobs: #{Delayed::Job.where('last_error IS NOT NULL').inspect}" end - break if success == 0 + break if success.zero? end UserInfo.current_user_id = original_user_id return diff --git a/app/models/transaction/trigger.rb b/app/models/transaction/trigger.rb index 7b71ba22d..524b8ab81 100644 --- a/app/models/transaction/trigger.rb +++ b/app/models/transaction/trigger.rb @@ -87,7 +87,7 @@ class Transaction::Trigger end ticket_count, tickets = Ticket.selectors(condition, 1) - next if ticket_count == 0 + next if ticket_count.zero? next if tickets.first.id != ticket.id # check if min one article attribute is used diff --git a/lib/stats/ticket_in_process.rb b/lib/stats/ticket_in_process.rb index c4f45041d..c76678d19 100644 --- a/lib/stats/ticket_in_process.rb +++ b/lib/stats/ticket_in_process.rb @@ -39,7 +39,7 @@ class Stats::TicketInProcess state = 'supergood' average_in_percent = '-' - if total != 0 + if total.nonzero? in_process_precent = ( count.to_f / (total.to_f / 100) ).round(1) end diff --git a/lib/stats/ticket_load_measure.rb b/lib/stats/ticket_load_measure.rb index b1c60dc58..8315e9b83 100644 --- a/lib/stats/ticket_load_measure.rb +++ b/lib/stats/ticket_load_measure.rb @@ -20,7 +20,7 @@ class Stats::TicketLoadMeasure total = count end - if total != 0 + if total.nonzero? load_measure_precent = ( count.to_f / (total.to_f / 100) ).round(3) end { diff --git a/lib/stats/ticket_reopen.rb b/lib/stats/ticket_reopen.rb index 6ef880a36..4107cd770 100644 --- a/lib/stats/ticket_reopen.rb +++ b/lib/stats/ticket_reopen.rb @@ -24,7 +24,7 @@ class Stats::TicketReopen end reopen_in_precent = 0 - if total != 0 + if total.nonzero? reopen_in_precent = ( count.to_f / (total.to_f / 100) ).round(3) end { diff --git a/lib/stats/ticket_response_time.rb b/lib/stats/ticket_response_time.rb index 7d44022ca..a896b0269 100644 --- a/lib/stats/ticket_response_time.rb +++ b/lib/stats/ticket_response_time.rb @@ -35,7 +35,7 @@ class Stats::TicketResponseTime end total += data[:time] } - if total != 0 + if total.nonzero? own = (own / count_own).round end {