diff --git a/Gemfile b/Gemfile index 05fc3e2..66fcc35 100644 --- a/Gemfile +++ b/Gemfile @@ -11,9 +11,9 @@ gem 'puma', '>= 5.0' # Bundle and transpile JavaScript [https://github.com/rails/jsbundling-rails] # gem 'jsbundling-rails' # Hotwire's SPA-like page accelerator [https://turbo.hotwired.dev] -gem 'turbo-rails' +# gem 'turbo-rails' # Hotwire's modest JavaScript framework [https://stimulus.hotwired.dev] -gem 'stimulus-rails' +# gem 'stimulus-rails' # Bundle and process CSS [https://github.com/rails/cssbundling-rails] # gem 'cssbundling-rails' # Build JSON APIs with ease [https://github.com/rails/jbuilder] @@ -167,4 +167,4 @@ gem 'cssbundling-rails', '~> 1.4' gem 'importmap-rails', '~> 2.1' -gem "rails_icons", "~> 1.3" +gem 'rails_icons', '~> 1.3' diff --git a/app/javascript/application.js b/app/javascript/application.js index dbd318d..53af1f5 100644 --- a/app/javascript/application.js +++ b/app/javascript/application.js @@ -1,5 +1,5 @@ // Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails -import "@hotwired/turbo-rails" +// import "@hotwired/turbo-rails" // import "controllers" // import Lightbox from "photoswipe"; @@ -154,8 +154,8 @@ function display_error(msg) { console.log("foo"); // }; -// document.addEventListener("DOMContentLoaded", () => { -document.addEventListener("turbo:load", () => { +document.addEventListener("DOMContentLoaded", () => { +// document.addEventListener("turbo:load", () => { console.log("DOM loaded"); // Handle uploads on specific views/pages. The DIV with ID // #data-js-upload-form carries data attributes that tell us where diff --git a/app/views/devise/sessions/new.slim b/app/views/devise/sessions/new.slim index e820310..0974677 100644 --- a/app/views/devise/sessions/new.slim +++ b/app/views/devise/sessions/new.slim @@ -37,14 +37,14 @@ hr -= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| += form_for(resource, as: resource_name, url: session_path(resource_name), data: { turbo: false }) do |f| = f.hidden_field :provider, value: 'local' .grid-x.grid-padding-x.align-center .cell.small-4 h4.text-center Debian staff login p.text-center - = link_to (icon('key-round'), text: 'Login via Salsa'), user_salsa_omniauth_authorize_path, class: 'button primary large', method: :post + = link_to icon('key-round') + 'Login via Salsa', user_salsa_omniauth_authorize_path, class: 'button primary large', method: :post .cell.small-4 h4.text-center Admin login p.text-center @@ -53,6 +53,7 @@ hr = f.submit "Sign in", class: 'button' + / - if devise_mapping.rememberable? / .small-6.cell / = f.check_box :remember_me diff --git a/app/views/my/_menu.slim b/app/views/my/_menu.slim index 8a78387..228a5df 100644 --- a/app/views/my/_menu.slim +++ b/app/views/my/_menu.slim @@ -29,6 +29,6 @@ / BUG: DELETE method is not used - if current_user li - = link_to destroy_user_session_path, data: { turbo_method: :delete } + = link_to destroy_user_session_path = icon 'lock' 'Logout diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index 608e0e3..9ddfac8 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -3,6 +3,14 @@ # Use this hook to configure devise mailer, warden hooks and so forth. # Many of these configuration options can be set straight in your model. Devise.setup do |config| + # When using Devise with Hotwire/Turbo, the http status for error responses + # and some redirects must match the following. The default in Devise for existing + # apps is `200 OK` and `302 Found` respectively, but new apps are generated with + # these new defaults that match Hotwire/Turbo behavior. + # Note: These might become the new default in future versions of Devise. + config.responder.error_status = :unprocessable_entity + config.responder.redirect_status = :see_other + # The secret key used by Devise. Devise uses this key to generate # random tokens. Changing this key will render invalid all existing # confirmation, reset password and unlock tokens in the database. @@ -41,7 +49,7 @@ Devise.setup do |config| # You can also supply a hash where the value is a boolean determining whether # or not authentication should be aborted when the value is not present. # config.authentication_keys = [:email] - config.authentication_keys = [:email, :provider] + config.authentication_keys = %i[email provider] # Configure parameters from the request object used for authentication. Each entry # given should be a request method and it will automatically be passed to the @@ -256,7 +264,7 @@ Devise.setup do |config| # config.navigational_formats = ['*/*', :html] # The default HTTP method used to sign out a resource. Default is :delete. - config.sign_out_via = :delete + config.sign_out_via = :get # ==> OmniAuth # Add a new OmniAuth provider. Check the wiki for more information on setting @@ -292,18 +300,18 @@ Devise.setup do |config| # Configuration: https://github.com/m0n9oose/omniauth_openid_connect config.omniauth :openid_connect, { name: :salsa, - scope: [:openid, :email, :profile], + scope: %i[openid email profile], discovery: true, - issuer: "https://salsa.debian.org", + issuer: 'https://salsa.debian.org', client_options: { port: 443, - scheme: "https", - host: "salsa.debian.org", + scheme: 'https', + host: 'salsa.debian.org', identifier: ENV['SALSA_OAUTH_KEY'], secret: ENV['SALSA_OAUTH_SECRET'], - #redirect_uri: "http://localhost:3000/users/auth/salsa/callback", + # redirect_uri: "http://localhost:3000/users/auth/salsa/callback", redirect_uri: "#{Rails.configuration.base_url}/users/auth/salsa/callback", - ssl: { ca_path: '/etc/ssl/certs'} + ssl: { ca_path: '/etc/ssl/certs' } } } OpenIDConnect.logger = Rails.logger