Skip to content

Commit

Permalink
Make sure we default to remembering logins, and remember them both fo…
Browse files Browse the repository at this point in the history
…r google oauth and email+password
  • Loading branch information
DanielJackson-Oslo committed Oct 1, 2024
1 parent dd49a21 commit fd96e09
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
3 changes: 3 additions & 0 deletions app/controllers/users/omniauth_callbacks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/views/devise/sessions/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>
</div>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion config/initializers/devise.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 1 addition & 5 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down

0 comments on commit fd96e09

Please sign in to comment.