From 519e6f1f79458dcd7dbacd56d796b627779041dc Mon Sep 17 00:00:00 2001 From: Pete Matsyburka Date: Sat, 2 Mar 2024 12:09:35 +0200 Subject: [PATCH] cleanup --- app/controllers/registrations_controller.rb | 62 -------------------- app/views/devise/registrations/new.html.erb | 47 --------------- app/views/devise/registrations/show.html.erb | 45 -------------- config/routes.rb | 9 --- 4 files changed, 163 deletions(-) delete mode 100644 app/controllers/registrations_controller.rb delete mode 100644 app/views/devise/registrations/new.html.erb delete mode 100644 app/views/devise/registrations/show.html.erb diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb deleted file mode 100644 index d0b4a403..00000000 --- a/app/controllers/registrations_controller.rb +++ /dev/null @@ -1,62 +0,0 @@ -# frozen_string_literal: true - -class RegistrationsController < Devise::RegistrationsController - prepend_before_action :require_no_authentication, only: [:show] - prepend_before_action :maybe_redirect_if_signed_in, only: [:show] - - def show; end - - def create - super - - Accounts.create_default_template(resource.account) if resource.account.persisted? - end - - private - - def after_sign_up_path_for(...) - if params[:redir].present? - return console_redirect_index_path(redir: params[:redir]) if params[:redir].starts_with?(Docuseal::CONSOLE_URL) - - return params[:redir] - end - - super - end - - def maybe_redirect_if_signed_in - return unless signed_in? - return if params[:redir].blank? - - redirect_to after_sign_up_path_for(current_user), allow_other_host: true - end - - def set_flash_message(key, kind, options = {}) - return if key == :alert && kind == 'already_authenticated' - - super - end - - def build_resource(_hash = {}) - account = Account.new(account_params) - account.timezone = Accounts.normalize_timezone(account.timezone) - - self.resource = account.users.new(user_params) - - account.name ||= resource.full_name if params[:action] == 'create' - end - - def user_params - return {} if params[:user].blank? - - params.require(:user).permit(:first_name, :last_name, :email, :password).compact_blank.tap do |attrs| - attrs[:password] ||= SecureRandom.hex if params[:action] == 'create' - end - end - - def account_params - return {} if params[:account].blank? - - params.require(:account).permit(:name, :timezone).compact_blank - end -end diff --git a/app/views/devise/registrations/new.html.erb b/app/views/devise/registrations/new.html.erb deleted file mode 100644 index ca60bd9f..00000000 --- a/app/views/devise/registrations/new.html.erb +++ /dev/null @@ -1,47 +0,0 @@ -
-

Profile Details

- <%= form_for('', as: resource_name, html: { class: 'space-y-6' }, data: { turbo: params[:redir].blank? }, url: new_registration_path) do |f| %> - <% if params[:redir].present? %> - <%= hidden_field_tag :redir, params[:redir] %> - <% end %> -
- <%= render 'devise/shared/error_messages', resource: %> - <%= f.fields_for resource do |ff| %> -
-
- <%= ff.label :first_name, class: 'label' %> - <%= ff.text_field :first_name, required: true, class: 'base-input' %> -
-
- <%= ff.label :last_name, class: 'label' %> - <%= ff.text_field :last_name, required: true, class: 'base-input' %> -
-
- <% end %> - <%= f.fields_for resource do |ff| %> -
- <%= ff.label :email, class: 'label' %> - <%= ff.email_field :email, value: EmailTypo.call(resource.email), required: true, class: 'base-input' %> -
- <% end %> - <%= f.fields_for resource.account do |ff| %> - - <%= ff.hidden_field :timezone %> -
- <%= ff.label :name, 'Company name (optional)', class: 'label' %> - <%= ff.text_field :name, class: 'base-input' %> -
- <% end %> - <%= f.fields_for resource do |ff| %> -
- <%= ff.label :password, class: 'label' %> - <%= ff.password_field :password, required: !params[:oauth_callback], class: 'base-input' %> -
- <% end %> -
-
- <%= f.button button_title(title: 'Sign up', disabled_with: 'Signing up'), class: 'base-button' %> -
- <% end %> - <%= render 'devise/shared/links' %> -
diff --git a/app/views/devise/registrations/show.html.erb b/app/views/devise/registrations/show.html.erb deleted file mode 100644 index 80490699..00000000 --- a/app/views/devise/registrations/show.html.erb +++ /dev/null @@ -1,45 +0,0 @@ -
- <% if params[:redir].to_s.ends_with?('on_premise') %> -

DocuSeal Console

-
- Sign up in DocuSeal Console to upgrade. - On-premises app is completely standalone, Console is used only to manage your license. -
- <% else %> - <%= render 'devise/shared/select_server' if Docuseal.multitenant? %> -

Create Free Account

- <% end %> - <%= form_for(User.new, html: { class: 'space-y-6' }, url: new_registration_path, data: { turbo: params[:redir].blank? }, method: :get) do |f| %> - <% if params[:redir].present? %> - <%= hidden_field_tag :redir, params[:redir] %> - <% end %> -
-
- <%= f.label :email, class: 'label' %> - <%= f.email_field :email, autofocus: true, autocomplete: 'email', class: 'base-input', placeholder: 'Enter email to continue' %> -
-
-
- <%= f.button button_title(title: 'Sign up', disabled_with: 'Sign up'), name: 'sign_up', value: true, class: 'base-button' %> -
- <% end %> - <% if devise_mapping.omniauthable? %> -
- <% if User.omniauth_providers.include?(:google_oauth2) %> - <%= form_for '', url: omniauth_authorize_path(resource_name, :google_oauth2), data: { turbo: false }, method: :post do |f| %> - - <%= hidden_field_tag :state, { redir: params[:redir].to_s }.compact_blank.to_query %> - <%= f.button button_title(title: 'Sign up with Google', icon: svg_icon('brand_google', class: 'w-6 h-6')), class: 'white-button w-full mt-4' %> - <% end %> - <% end %> - <% if User.omniauth_providers.include?(:microsoft_office365) %> - <%= form_for '', url: omniauth_authorize_path(resource_name, :microsoft_office365), data: { turbo: false }, method: :post do |f| %> - - <%= hidden_field_tag :state, { redir: params[:redir].to_s }.compact_blank.to_query, id: 'state_microsoft' %> - <%= f.button button_title(title: 'Sign up with Microsoft', icon: svg_icon('brand_microsoft', class: 'w-6 h-6')), class: 'white-button w-full' %> - <% end %> - <% end %> -
- <% end %> - <%= render 'devise/shared/links' %> -
diff --git a/config/routes.rb b/config/routes.rb index 1c88b723..076704f0 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -17,15 +17,6 @@ Rails.application.routes.draw do end devise_scope :user do - if Docuseal.multitenant? - resource :registration, only: %i[show], path: 'sign_up' - unauthenticated do - resource :registration, only: %i[create], path: 'new' do - get '' => :new, as: :new - end - end - end - resource :invitation, only: %i[update] do get '' => :edit end