Skip to content

Commit

Permalink
A couple of Devise bug fixes (#84)
Browse files Browse the repository at this point in the history
* Fix sign_in, sign_out routes

* Remember users on login
  • Loading branch information
nathanmsmith committed May 8, 2023
1 parent 2ac10ba commit 0181d0d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions app/controllers/omniauth_callbacks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

class OmniauthCallbacksController < Devise::OmniauthCallbacksController
extend T::Sig
include Devise::Controllers::Rememberable

# skip_before_action :authenticate_user!, raise: false
skip_before_action :verify_authenticity_token, only: :google_oauth2
Expand All @@ -12,6 +13,8 @@ def google_oauth2
auth = request.env["omniauth.auth"]
user = User.from_omniauth(auth, referral_code: cookies[:referral_code])

remember_me(user)

if user.persisted?
flash[:success] = "Successfully logged in! Welcome to Hotseat!"
sign_in_and_redirect(user)
Expand Down
4 changes: 2 additions & 2 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
}

devise_scope :user do
get "sign_in", to: "sessions#new", as: :new_user_session
delete "sign_out", to: "sessions#destroy", as: :destroy_user_session
get "sign_in", to: "devise/sessions#new", as: :new_user_session
delete "sign_out", to: "devise/sessions#destroy", as: :destroy_user_session
end

mount Ahoy::Engine => "/hotcount"
Expand Down

0 comments on commit 0181d0d

Please sign in to comment.