diff --git a/app/controllers/users/omniauth_callbacks_controller.rb b/app/controllers/users/omniauth_callbacks_controller.rb index ab0c9412..dfb45dc4 100644 --- a/app/controllers/users/omniauth_callbacks_controller.rb +++ b/app/controllers/users/omniauth_callbacks_controller.rb @@ -2,10 +2,13 @@ module Users class OmniauthCallbacksController < Devise::OmniauthCallbacksController + include Devise::Controllers::Rememberable + def google_oauth2 # rubocop:disable Metrics/AbcSize user = User.from_google(email: auth.info.email, first_name: auth.info.first_name, last_name: auth.info.last_name) if user.present? + remember_me(user) sign_out_all_scopes sign_in_and_redirect user else diff --git a/app/views/devise/sessions/new.html.erb b/app/views/devise/sessions/new.html.erb index a1fa25a6..0a7a2dfa 100644 --- a/app/views/devise/sessions/new.html.erb +++ b/app/views/devise/sessions/new.html.erb @@ -47,7 +47,7 @@ <%= t('simple_form.labels.user.session.login_with_email') %> <% end %> <% if devise_mapping.rememberable? %> - <%= f.input :remember_me, as: :boolean, wrapper_html: { class: "flex items-center" } %> + <%= f.input :remember_me, as: :boolean, input_html: {checked: 'checked'}, wrapper_html: { class: "flex items-center" } %> <% end %> <% end %> diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index fe8d3689..52a58ab6 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -98,7 +98,7 @@ # Notice that if you are skipping storage for all authentication paths, you # may want to disable generating routes to Devise's sessions controller by # passing skip: :sessions to `devise_for` in your config/routes.rb - config.skip_session_storage = [:http_auth] + # config.skip_session_storage = [:http_auth] # By default, Devise cleans up the CSRF token on authentication to # avoid CSRF token fixation attacks. This means that, when using AJAX diff --git a/config/routes.rb b/config/routes.rb index 042e3b26..96ec1d33 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -14,14 +14,10 @@ devise_scope :user do authenticated :user do root to: "spaces#index" + get "session", to: "devise/sessions#edit", as: "edit_session" end end - # Devise addons - devise_scope :user do - get "session", to: "devise/sessions#edit", as: "edit_session" - end - # Homepage for unauthenticated users root to: "high_voltage/pages#show", id: "frontpage", as: "unauthenticated_root"