From 1c4524de81fb1fc5c111f5f4e96c186a352b9605 Mon Sep 17 00:00:00 2001 From: Rolf Schmidt Date: Fri, 7 May 2021 11:52:45 +0000 Subject: [PATCH] Fixes #3508 - new _plugin dir introduces auth:login events which will never get triggered. --- .../wizard_modal_full_screen.coffee | 4 +--- .../app/controllers/_dashboard/activity_stream.coffee | 2 ++ .../app/controllers/_plugin/default_locale.coffee | 3 +-- .../app/controllers/_plugin/default_timezone.coffee | 3 +-- .../javascripts/app/controllers/_plugin/notify.coffee | 8 +++----- .../app/controllers/_plugin/session_timeout.coffee | 10 ++++++---- .../app/controllers/_plugin/switch_back_to_user.coffee | 6 ------ .../app/controllers/_plugin/translation_support.coffee | 3 +-- .../app/controllers/_plugin/user_signup_check.coffee | 4 ---- app/assets/javascripts/app/controllers/login.coffee | 1 - app/assets/javascripts/app/lib/app_post/auth.coffee | 1 - .../javascripts/app/models/_application_model.coffee | 2 ++ .../javascripts/app/models/data_privacy_task.coffee | 3 +++ app/assets/javascripts/app/models/organization.coffee | 3 +++ app/assets/javascripts/app/models/role.coffee | 3 +++ app/assets/javascripts/app/models/ticket.coffee | 2 ++ .../javascripts/app/models/ticket_article.coffee | 2 ++ app/assets/javascripts/app/models/user.coffee | 3 +++ 18 files changed, 33 insertions(+), 30 deletions(-) diff --git a/app/assets/javascripts/app/controllers/_application_controller/wizard_modal_full_screen.coffee b/app/assets/javascripts/app/controllers/_application_controller/wizard_modal_full_screen.coffee index e06bf7b4e..613ee6429 100644 --- a/app/assets/javascripts/app/controllers/_application_controller/wizard_modal_full_screen.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller/wizard_modal_full_screen.coffee @@ -5,6 +5,4 @@ class App.ControllerWizardFullScreen extends App.ControllerWizardModal # login check / get session user redirectToLogin: => App.Auth.loginCheck() - @el.remove() - App.Plugin.init() - @navigate '#', { removeEl: true } + @navigate('#', { removeEl: true }) diff --git a/app/assets/javascripts/app/controllers/_dashboard/activity_stream.coffee b/app/assets/javascripts/app/controllers/_dashboard/activity_stream.coffee index d0a521fc3..bbb0e363a 100644 --- a/app/assets/javascripts/app/controllers/_dashboard/activity_stream.coffee +++ b/app/assets/javascripts/app/controllers/_dashboard/activity_stream.coffee @@ -59,6 +59,8 @@ class App.DashboardActivityStream extends App.CollectionController @el.closest('.sidebar').find('.activity-description').addClass('hidden') onRenderItemEnd: (item, el) -> + return if App.Session.get() is undefined + new App.WidgetAvatar( el: el.find('.js-avatar') object_id: item.created_by_id diff --git a/app/assets/javascripts/app/controllers/_plugin/default_locale.coffee b/app/assets/javascripts/app/controllers/_plugin/default_locale.coffee index 98099c2ed..74e06f885 100644 --- a/app/assets/javascripts/app/controllers/_plugin/default_locale.coffee +++ b/app/assets/javascripts/app/controllers/_plugin/default_locale.coffee @@ -16,8 +16,7 @@ class DefaultLocale extends App.Controller processData: true ) - @controllerBind('auth:login', (session) => + if App.Session.get() isnt undefined @delay(check, 3500, 'default_locale') - ) App.Config.set('default_locale', DefaultLocale, 'Plugins') diff --git a/app/assets/javascripts/app/controllers/_plugin/default_timezone.coffee b/app/assets/javascripts/app/controllers/_plugin/default_timezone.coffee index 0f25ad6d6..2b341a229 100644 --- a/app/assets/javascripts/app/controllers/_plugin/default_timezone.coffee +++ b/app/assets/javascripts/app/controllers/_plugin/default_timezone.coffee @@ -26,9 +26,8 @@ class DefaultTimezone extends App.Controller # processData: true #) - @controllerBind('auth:login', (session) => + if App.Session.get() isnt undefined @delay(check, 8500, 'default_timezone') - ) updateSetting: (timezone) -> App.Setting.set('timezone_default', timezone) diff --git a/app/assets/javascripts/app/controllers/_plugin/notify.coffee b/app/assets/javascripts/app/controllers/_plugin/notify.coffee index b275f13e2..3637edd7f 100644 --- a/app/assets/javascripts/app/controllers/_plugin/notify.coffee +++ b/app/assets/javascripts/app/controllers/_plugin/notify.coffee @@ -51,11 +51,9 @@ class App.Notify extends App.Controller ) # request desktop notification after login - @controllerBind('auth', (data) -> - if !_.isEmpty(data) - return if !window.Notification - window.Notification.requestPermission() - ) + if App.Session.get() isnt undefined && window.Notification + window.Notification.requestPermission() + $(window).focus( => for counter, notification of @desktopNotify diff --git a/app/assets/javascripts/app/controllers/_plugin/session_timeout.coffee b/app/assets/javascripts/app/controllers/_plugin/session_timeout.coffee index adce4081e..56529eafe 100644 --- a/app/assets/javascripts/app/controllers/_plugin/session_timeout.coffee +++ b/app/assets/javascripts/app/controllers/_plugin/session_timeout.coffee @@ -5,14 +5,16 @@ class SessionTimeout extends App.Controller super lastEvent = new Date().getTime() - check_timeout = => + checkTimeout = => return if new Date().getTime() - 1000 < lastEvent lastEvent = new Date().getTime() @checkLogout() - $(document).off('keyup.session_timeout').on('keyup.session_timeout', check_timeout) - $(document).off('mousemove.session_timeout').on('mousemove.session_timeout', check_timeout) - @controllerBind('config_update', check_timeout) + # reset timeout on mouse move + $(document).off('keyup.session_timeout').on('keyup.session_timeout', checkTimeout) + $(document).off('mousemove.session_timeout').on('mousemove.session_timeout', checkTimeout) + + @controllerBind('config_update', checkTimeout) @controllerBind('session_timeout', @quitApp) @interval(@checkLogout, 5000, 'session_timeout') diff --git a/app/assets/javascripts/app/controllers/_plugin/switch_back_to_user.coffee b/app/assets/javascripts/app/controllers/_plugin/switch_back_to_user.coffee index e32fe07eb..455f325fa 100644 --- a/app/assets/javascripts/app/controllers/_plugin/switch_back_to_user.coffee +++ b/app/assets/javascripts/app/controllers/_plugin/switch_back_to_user.coffee @@ -14,12 +14,6 @@ class SwitchBackToUser extends App.Controller @render() ) - # remove widget - @controllerBind('auth:logout', => - App.Config.set('switch_back_to_possible', false) - @render() - ) - render: (user) -> # if no switch to user is active diff --git a/app/assets/javascripts/app/controllers/_plugin/translation_support.coffee b/app/assets/javascripts/app/controllers/_plugin/translation_support.coffee index 189a4e96f..793e593df 100644 --- a/app/assets/javascripts/app/controllers/_plugin/translation_support.coffee +++ b/app/assets/javascripts/app/controllers/_plugin/translation_support.coffee @@ -27,9 +27,8 @@ class TranslationSupport extends App.Controller @controllerBind('i18n:language:change', => @delay(check, 2500, 'translation_support') ) - @controllerBind('auth:login', => + if App.Session.get() isnt undefined @delay(check, 2500, 'translation_support') - ) App.Config.set( 'translaton_support', TranslationSupport, 'Plugins' ) diff --git a/app/assets/javascripts/app/controllers/_plugin/user_signup_check.coffee b/app/assets/javascripts/app/controllers/_plugin/user_signup_check.coffee index 359840909..2dd98bd09 100644 --- a/app/assets/javascripts/app/controllers/_plugin/user_signup_check.coffee +++ b/app/assets/javascripts/app/controllers/_plugin/user_signup_check.coffee @@ -7,10 +7,6 @@ class UserSignupCheck extends App.Controller new Modal(user: user) ) - @controllerBind('auth:login', (user) => - return if !user - @verifyLater(user.id) - ) user = App.User.current() @verifyLater(user.id) if user? diff --git a/app/assets/javascripts/app/controllers/login.coffee b/app/assets/javascripts/app/controllers/login.coffee index c7bb85806..bb921dfe4 100644 --- a/app/assets/javascripts/app/controllers/login.coffee +++ b/app/assets/javascripts/app/controllers/login.coffee @@ -76,7 +76,6 @@ class Login extends App.ControllerFullPage ) success: (data, status, xhr) => - App.Plugin.init() # redirect to # @log 'notice', 'REDIRECT to -#/-' diff --git a/app/assets/javascripts/app/lib/app_post/auth.coffee b/app/assets/javascripts/app/lib/app_post/auth.coffee index 8fd411422..426c3782e 100644 --- a/app/assets/javascripts/app/lib/app_post/auth.coffee +++ b/app/assets/javascripts/app/lib/app_post/auth.coffee @@ -159,7 +159,6 @@ class App.Auth if _.isFunction(model_object.clearInMemory) model_object.clearInMemory() - App.Plugin.init() App.Event.trigger('auth') App.Event.trigger('auth:logout') diff --git a/app/assets/javascripts/app/models/_application_model.coffee b/app/assets/javascripts/app/models/_application_model.coffee index 2b2136d25..a9370e0b1 100644 --- a/app/assets/javascripts/app/models/_application_model.coffee +++ b/app/assets/javascripts/app/models/_application_model.coffee @@ -850,6 +850,8 @@ set new attributes of model (remove already available attributes) collection activityMessage: (item) -> + return if !item + return "Need own activityMessage() in model to generate text (#{@objectDisplayName()}/#{item.type})." @lastUpdatedAt: -> diff --git a/app/assets/javascripts/app/models/data_privacy_task.coffee b/app/assets/javascripts/app/models/data_privacy_task.coffee index 72e63cdc7..0c337ff15 100644 --- a/app/assets/javascripts/app/models/data_privacy_task.coffee +++ b/app/assets/javascripts/app/models/data_privacy_task.coffee @@ -21,6 +21,9 @@ Data Privacy tasks will be executed every 10 minutes. The execution might take s ''' activityMessage: (item) -> + return if !item + return if !item.created_by + if item.type is 'create' return App.i18n.translateContent('%s created data privacy task to delete user id |%s|', item.created_by.displayName(), item.objectNative.deletable_id) else if item.type is 'update' diff --git a/app/assets/javascripts/app/models/organization.coffee b/app/assets/javascripts/app/models/organization.coffee index 04b00abc6..969091f13 100644 --- a/app/assets/javascripts/app/models/organization.coffee +++ b/app/assets/javascripts/app/models/organization.coffee @@ -48,6 +48,9 @@ Using **Organisations** you can **group** customers. This has among others two i icon: 'organization' activityMessage: (item) -> + return if !item + return if !item.created_by + if item.type is 'create' return App.i18n.translateContent('%s created Organization |%s|', item.created_by.displayName(), item.title) else if item.type is 'update' diff --git a/app/assets/javascripts/app/models/role.coffee b/app/assets/javascripts/app/models/role.coffee index 974ad85c3..ff6979c72 100644 --- a/app/assets/javascripts/app/models/role.coffee +++ b/app/assets/javascripts/app/models/role.coffee @@ -19,6 +19,9 @@ class App.Role extends App.Model ] activityMessage: (item) -> + return if !item + return if !item.created_by + if item.type is 'create' return App.i18n.translateContent('%s created Role |%s|', item.created_by.displayName(), item.title) else if item.type is 'update' diff --git a/app/assets/javascripts/app/models/ticket.coffee b/app/assets/javascripts/app/models/ticket.coffee index fdcdb2e63..b70774167 100644 --- a/app/assets/javascripts/app/models/ticket.coffee +++ b/app/assets/javascripts/app/models/ticket.coffee @@ -98,6 +98,8 @@ class App.Ticket extends App.Model activityMessage: (item) -> return if !item + return if !item.created_by + if item.type is 'create' return App.i18n.translateContent('%s created Ticket |%s|', item.created_by.displayName(), item.title) else if item.type is 'update' diff --git a/app/assets/javascripts/app/models/ticket_article.coffee b/app/assets/javascripts/app/models/ticket_article.coffee index 84e5d7f80..0ab042b2d 100644 --- a/app/assets/javascripts/app/models/ticket_article.coffee +++ b/app/assets/javascripts/app/models/ticket_article.coffee @@ -43,6 +43,8 @@ class App.TicketArticle extends App.Model activityMessage: (item) -> return if !item + return if !item.created_by + if item.type is 'create' return App.i18n.translateContent('%s created Article for |%s|', item.created_by.displayName(), item.title) else if item.type is 'update' diff --git a/app/assets/javascripts/app/models/user.coffee b/app/assets/javascripts/app/models/user.coffee index c07c0f993..8ff31425c 100644 --- a/app/assets/javascripts/app/models/user.coffee +++ b/app/assets/javascripts/app/models/user.coffee @@ -163,6 +163,9 @@ class App.User extends App.Model icon: 'user' activityMessage: (item) -> + return if !item + return if !item.created_by + if item.type is 'create' return App.i18n.translateContent('%s created User |%s|', item.created_by.displayName(), item.title) else if item.type is 'update'