From e75e7b18b437452f26da12969610e18ac01ba277 Mon Sep 17 00:00:00 2001 From: Alex Turchyn Date: Sat, 5 Aug 2023 21:39:59 +0300 Subject: [PATCH] developer console fixes --- .dockerignore | 1 + app/controllers/console_redirect_controller.rb | 2 +- app/javascript/elements/menu_active.js | 2 +- app/models/user.rb | 3 +-- app/views/shared/_settings_nav.html.erb | 13 +++++++++---- config/application.rb | 2 +- config/initializers/devise.rb | 2 +- config/routes.rb | 6 ++++-- 8 files changed, 19 insertions(+), 12 deletions(-) diff --git a/.dockerignore b/.dockerignore index c085d97c..107e1389 100644 --- a/.dockerignore +++ b/.dockerignore @@ -27,3 +27,4 @@ /attachments /docuseal .DS_Store +.env diff --git a/app/controllers/console_redirect_controller.rb b/app/controllers/console_redirect_controller.rb index 2424c9da..ba3565dc 100644 --- a/app/controllers/console_redirect_controller.rb +++ b/app/controllers/console_redirect_controller.rb @@ -3,7 +3,7 @@ class ConsoleRedirectController < ApplicationController def index auth = JsonWebToken.encode(uuid: current_user.uuid, - action: :sign_in, + scope: :console, exp: 1.minute.from_now.to_i) redirect_to("#{Docuseal::CONSOLE_URL}?#{{ auth: }.to_query}", allow_other_host: true) diff --git a/app/javascript/elements/menu_active.js b/app/javascript/elements/menu_active.js index e9c434d2..819e9259 100644 --- a/app/javascript/elements/menu_active.js +++ b/app/javascript/elements/menu_active.js @@ -1,7 +1,7 @@ export default class extends HTMLElement { connectedCallback () { this.querySelectorAll('a').forEach((link) => { - if (document.location.pathname.startsWith(link.pathname)) { + if (document.location.pathname.startsWith(link.pathname) && !link.getAttribute('href').startsWith('http')) { link.classList.add('bg-base-300') } }) diff --git a/app/models/user.rb b/app/models/user.rb index 7e7e023b..8d5a098e 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -42,8 +42,7 @@ class User < ApplicationRecord ROLES = %w[admin].freeze - EMAIL_REGEXP = - /[a-z0-9][.']?(?:(?:[a-z0-9_-]++[.'])*[a-z0-9_-]++)*@(?:[a-z0-9]++[.-])*[a-z0-9]++\.[a-z]{2,}/i + EMAIL_REGEXP = /[^@,\s]+@[^@,\s]+/ belongs_to :account diff --git a/app/views/shared/_settings_nav.html.erb b/app/views/shared/_settings_nav.html.erb index 13e663c4..5700bc14 100644 --- a/app/views/shared/_settings_nav.html.erb +++ b/app/views/shared/_settings_nav.html.erb @@ -23,7 +23,7 @@
  • <%= link_to 'Team', settings_users_path, class: 'text-base hover:bg-base-300' %>
  • - <% unless Docuseal.multitenant? %> + <% if Docuseal.demo? || !Docuseal.multitenant? %>
  • <%= link_to 'API', settings_api_index_path, class: 'text-base hover:bg-base-300' %>
  • @@ -31,9 +31,14 @@ <%= link_to 'Webhooks', settings_webhooks_path, class: 'text-base hover:bg-base-300' %> <% end %> -
  • - <%= link_to 'Console', console_redirect_index_path, class: 'text-base hover:bg-base-300' %> -
  • + <% unless Docuseal.demo? %> +
  • + <%= link_to Docuseal.multitenant? ? console_redirect_index_path : Docuseal::CONSOLE_URL, class: 'text-base hover:bg-base-300' do %> + Console + New + <% end %> +
  • + <% end %>