Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

remove auto login tokens components

Behrokh Satarnejad589ca70a8adc
diff --git a/app/components/users/auto_login_tokens/row_component.rb b/app/components/users/auto_login_tokens/row_component.rb
deleted file mode 100644
index d79cc05bf31..00000000000
--- a/app/components/users/auto_login_tokens/row_component.rb
+++ /dev/null
@@ -1,115 +0,0 @@
-# frozen_string_literal: true
-
-#-- copyright
-# OpenProject is an open source project management software.
-# Copyright (C) the OpenProject GmbH
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License version 3.
-#
-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
-# Copyright (C) 2006-2013 Jean-Philippe Lang
-# Copyright (C) 2010-2013 the ChiliProject Team
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-# See COPYRIGHT and LICENSE files for more details.
-#++
-
-module Users
- module AutoLoginTokens
- class RowComponent < ::OpPrimer::BorderBoxRowComponent
- delegate :current_token, to: :table
-
- def token
- model
- end
-
- delegate :data, to: :token, prefix: true
-
- def current?
- token == current_token
- end
-
- def is_current # rubocop:disable Naming/PredicateName
- if current?
- helpers.op_icon "icon-yes"
- end
- end
-
- def device
- token_data[:platform] || I18n.t("users.sessions.unknown_os")
- end
-
- def browser
- name = token_data[:browser] || "unknown browser"
- version = token_data[:browser_version]
- "#{name} #{version ? "(Version #{version})" : ''}"
- end
-
- def platform
- token_data[:platform] || "unknown platform"
- end
-
- def expires_on
- expires = token.expires_on || (token.created_at + Setting.autologin.days)
- helpers.format_date(expires)
- end
-
- def actions
- action_menu
- end
-
- private
-
- def button_links
- [action_menu]
- end
-
- def action_menu
- render(Primer::Alpha::ActionMenu.new(anchor_align: :end)) do |menu|
- menu.with_show_button(
- icon: "kebab-horizontal",
- "aria-label": t(:label_more),
- scheme: :invisible,
-
- data: { "test-selector": "more-button" }
- )
- delete_action(menu)
- end
- end
-
- def delete_action(menu)
- return if current?
-
- menu.with_item(
- label: I18n.t(:button_delete),
- scheme: :danger,
- href: url_for({ controller: "/my/auto_login_tokens", action: "destroy", id: token.id }),
- tag: :button,
- form_arguments: { method: :delete },
- content_arguments: {
- data: {
- confirm: I18n.t(:text_are_you_sure),
- disable_with: I18n.t(:label_loading)
- }
- }
- ) do |item|
- item.with_leading_visual_icon(icon: :trash)
- end
- end
- end
- end
-end
diff --git a/app/components/users/auto_login_tokens/table_component.rb b/app/components/users/auto_login_tokens/table_component.rb
deleted file mode 100644
index fc0a6a239c9..00000000000
--- a/app/components/users/auto_login_tokens/table_component.rb
+++ /dev/null
@@ -1,57 +0,0 @@
-# frozen_string_literal: true
-
-#-- copyright
-# OpenProject is an open source project management software.
-# Copyright (C) the OpenProject GmbH
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License version 3.
-#
-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
-# Copyright (C) 2006-2013 Jean-Philippe Lang
-# Copyright (C) 2010-2013 the ChiliProject Team
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-# See COPYRIGHT and LICENSE files for more details.
-#++
-
-module Users
- module AutoLoginTokens
- class TableComponent < ::OpPrimer::BorderBoxTableComponent
- columns :is_current, :browser, :device, :expires_on
- sortable_columns :updated_at
- options :current_token
- mobile_columns :is_current, :browser, :device, :expires_on
-
- def mobile_title
- t("users.sessions.remembered_devices")
- end
-
- def has_actions?
- true
- end
-
- def headers
- [
- [:is_current, { caption: I18n.t("users.sessions.current") }],
- [:browser, { caption: I18n.t("users.sessions.browser") }],
- [:device, { caption: I18n.t("users.sessions.device") }],
- [:expires_on, { caption: I18n.t("attributes.expires_at") }]
- ]
- end
- end
- end
-end
diff --git a/app/components/users/sessions/row_component.rb b/app/components/users/sessions/row_component.rb
index f7a81cf337c..8ab366aeecf 100644
--- a/app/components/users/sessions/row_component.rb
+++ b/app/components/users/sessions/row_component.rb
@@ -46,6 +46,10 @@ module Users
record.is_a?(::Token::AutoLogin)
end
+ def current?
+ (session? && record.current?(current_session)) || (token? && record == current_token)
+ end
+
def browser
return I18n.t("users.sessions.unknown_browser") unless session? || token?
@@ -72,7 +76,7 @@ module Users
end
def updated_at
- if session? && record.current?(current_session)
+ if current?
I18n.t("users.sessions.current")
elsif token?
helpers.format_time(record.created_at)
diff --git a/config/locales/en.yml b/config/locales/en.yml
index d18dc6e1e89..f32a4ac7545 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -666,8 +666,6 @@ en:
autologins:
prompt: "Stay logged in for %{num_days}"
sessions:
- remembered_devices: "Remembered devices"
- remembered_devices_caption: "A list of all devices that logged into this account using the 'Stay logged in' option."
session_name: "%{browser_name} %{browser_version} on %{os_name}"
browser: "Browser"
expires: "Expires"
@@ -675,9 +673,9 @@ en:
device: "Device / OS"
unknown_browser: "unknown browser"
unknown_os: "unknown operating system"
- current: "Current session"
+ current: "Current (this device)"
title: "Session management"
- instructions: "This is a list of devices that have logged into your account. Revoke any sessions that you do not recognize or you have no longer access to."
+ instructions: "You are logged in to your account through the following devices. Revoke sessions that you do not recognise or from devices you do not control."
may_not_delete_current: "You cannot delete your current session."
groups:
member_in_these_groups: "This user is currently a member of the following groups:"