diff --git a/app/controllers/application_controller/with_domain.rb b/app/controllers/application_controller/with_domain.rb index 6311d132c8ee6c5ff8adba5992a960205c52a822..95edbff9d84a85214ba910175c7adfe573f154e2 100644 --- a/app/controllers/application_controller/with_domain.rb +++ b/app/controllers/application_controller/with_domain.rb @@ -26,5 +26,10 @@ module ApplicationController::WithDomain end end helper_method :current_context + + def current_mode + current_extranet.present? ? 'extranet' : 'university' + end + helper_method :current_mode end end diff --git a/app/controllers/concerns/users/layout_choice.rb b/app/controllers/concerns/users/layout_choice.rb new file mode 100644 index 0000000000000000000000000000000000000000..2721bd54cba972f621bc7025a7aab39b2c062ff7 --- /dev/null +++ b/app/controllers/concerns/users/layout_choice.rb @@ -0,0 +1,20 @@ +module Users::LayoutChoice + extend ActiveSupport::Concern + + included do + layout :extranet_or_default + end + + private + + def extranet_or_default + # extranet have their custom devise layout + # university osuny sessions have an "admin" layout for registration edit/update, else default devise layout. + case current_mode + when 'extranet' + 'extranet/layouts/devise' + when 'university' + (controller_path == 'users/registrations' && ['edit', 'update'].include?(action_name)) ? 'admin/layouts/application' : 'devise' + end + end +end diff --git a/app/controllers/users/confirmations_controller.rb b/app/controllers/users/confirmations_controller.rb index 663067dd4e608b06cbb1caeaa10f99e7fc245f42..2d4b6116e699ad6392c763d02a0dd175d1ce54ef 100644 --- a/app/controllers/users/confirmations_controller.rb +++ b/app/controllers/users/confirmations_controller.rb @@ -1,5 +1,6 @@ class Users::ConfirmationsController < Devise::ConfirmationsController include Users::AddUniversityToRequestParams + include Users::LayoutChoice def resend unless signed_in_resource.confirmed? diff --git a/app/controllers/users/omniauth_callbacks_controller.rb b/app/controllers/users/omniauth_callbacks_controller.rb index 47b36fc4d6bb9823d4f47ddda8486fe7f53d70e1..924bb342973e83ac00a53f4024484c79aeac8c96 100644 --- a/app/controllers/users/omniauth_callbacks_controller.rb +++ b/app/controllers/users/omniauth_callbacks_controller.rb @@ -1,7 +1,9 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController # include Users::AddBrandToRequestParams + # include Users::LayoutChoice # include I18nHelper + protect_from_forgery except: :saml before_action :redirect_unless_university_has_sso skip_before_action :verify_authenticity_token, only: :saml diff --git a/app/controllers/users/passwords_controller.rb b/app/controllers/users/passwords_controller.rb index c0334ec485bd903f30bf6324a25e1b245ffd4c2e..49d967b4a033355dbcca5e64e6d9e93d1854a1fe 100644 --- a/app/controllers/users/passwords_controller.rb +++ b/app/controllers/users/passwords_controller.rb @@ -1,5 +1,6 @@ class Users::PasswordsController < Devise::PasswordsController include Users::AddUniversityToRequestParams + include Users::LayoutChoice def update super do |resource| diff --git a/app/controllers/users/registrations_controller.rb b/app/controllers/users/registrations_controller.rb index 4e22f2bc2836ec5e89fcc8ca944ee2f9a3034174..8ce23d804c17e356a42a3449dab5164ee1567c8c 100644 --- a/app/controllers/users/registrations_controller.rb +++ b/app/controllers/users/registrations_controller.rb @@ -1,7 +1,6 @@ class Users::RegistrationsController < Devise::RegistrationsController include Users::AddUniversityToRequestParams - - layout 'admin/layouts/application', only: [:edit, :update] + include Users::LayoutChoice before_action :configure_sign_up_params, only: :create before_action :configure_account_update_params, only: :update diff --git a/app/controllers/users/sessions_controller.rb b/app/controllers/users/sessions_controller.rb index 719343815f218d7c8ca598bee06f39e1f321d4d1..41758961c657e1597c9287762fd454a5ac52e91e 100644 --- a/app/controllers/users/sessions_controller.rb +++ b/app/controllers/users/sessions_controller.rb @@ -1,10 +1,11 @@ class Users::SessionsController < Devise::SessionsController include Users::AddUniversityToRequestParams + include Users::LayoutChoice # DELETE /resource/sign_out def destroy current_user.invalidate_all_sessions! super end - + end diff --git a/app/controllers/users/two_factor_authentication_controller.rb b/app/controllers/users/two_factor_authentication_controller.rb index 1ab0e9e273a370736fb50634cba2a345a857061f..bc2df18276b7835ccb78b7d5414a9e900ea29cb6 100644 --- a/app/controllers/users/two_factor_authentication_controller.rb +++ b/app/controllers/users/two_factor_authentication_controller.rb @@ -1,2 +1,4 @@ class Users::TwoFactorAuthenticationController < Devise::TwoFactorAuthenticationController + include Users::LayoutChoice + end diff --git a/app/controllers/users/unlocks_controller.rb b/app/controllers/users/unlocks_controller.rb index b1ef889214da83bd699990b4c1110d132a004626..47d30a6a53e2c1696cfb166427bc8ec8764a7b14 100644 --- a/app/controllers/users/unlocks_controller.rb +++ b/app/controllers/users/unlocks_controller.rb @@ -1,3 +1,4 @@ class Users::UnlocksController < Devise::UnlocksController include Users::AddUniversityToRequestParams + include Users::LayoutChoice end diff --git a/app/views/extranet/application/_footer.html.erb b/app/views/extranet/application/_footer.html.erb index 0ea2da91e584d5cee8ea31a267f16ca24323f3ba..ccb9d2c5416b39c9c5576fdc447fa59a1d83bad6 100644 --- a/app/views/extranet/application/_footer.html.erb +++ b/app/views/extranet/application/_footer.html.erb @@ -1,8 +1,12 @@ +<% hide_logo ||= false %> + <footer class="pt-5"> <div class="container"> - <div class="footer-logo pb-5 mb-5 text-center"> - <%= render 'logo' %> - </div> + <% unless hide_logo %> + <div class="footer-logo pb-5 mb-5 text-center"> + <%= render 'logo' %> + </div> + <% end %> <div class="row justify-space-between"> <% if current_extranet.about.is_a?(Education::School) %> <address class="col-md-6" itemscope itemtype="https://schema.org/CollegeOrUniversity"> diff --git a/app/views/extranet/layouts/devise.html.erb b/app/views/extranet/layouts/devise.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..99338798244982206be52a840118584286e7d74d --- /dev/null +++ b/app/views/extranet/layouts/devise.html.erb @@ -0,0 +1,40 @@ +<!DOCTYPE html> +<html> + <head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> + <title><%= yield :title %></title> + <%= csrf_meta_tags %> + <%= csp_meta_tag %> + <%= stylesheet_link_tag 'admin', media: 'all' %> + <%= javascript_include_tag 'admin' %> + <%= favicon_link_tag 'favicon.png' %> + </head> + <body class="<%= body_classes %>"> + <div class="container"> + <div class="row"> + <div class="col-sm-10 mx-auto"> + <h1 class="my-5 py-5 text-center"> + <%= link_to root_path do %> + <%= render 'logo' %> + <% end %> + </h1> + <div class="card"> + <div class="card-body text-start"> + <% unless notice.blank? %> + <div class="alert alert-success mt-2" role="alert"><%= notice.html_safe %></div> + <% end %> + <% unless alert.blank? %> + <div class="alert alert-danger mt-2" role="alert"><%= alert.html_safe %></div> + <% end %> + <%= yield %> + </div> + </div> + </div> + </div> + </div> + <%= render 'extranet/application/footer', hide_logo: true %> + <%= render 'gdpr/cookie_consent' %> + <%= render 'bugsnag' %> + </body> +</html> diff --git a/db/schema.rb b/db/schema.rb index cb9d994e1ed2bd88e37a90faec20b0a2c1434c90..7762689058578b09ed9655acfe8fcdfe07b422b7 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -44,7 +44,7 @@ ActiveRecord::Schema.define(version: 2022_10_11_070402) do t.text "metadata" t.string "service_name", null: false t.bigint "byte_size", null: false - t.string "checksum" + t.string "checksum", null: false t.datetime "created_at", null: false t.uuid "university_id" t.index ["key"], name: "index_active_storage_blobs_on_key", unique: true