Skip to content

Commit 23f9855

Browse files
committed
WIP: attempt to correctly sign_in the user after oauth
1 parent 15ca1a1 commit 23f9855

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

app/controllers/better_together/omniauth_callbacks_controller.rb

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,15 @@ def github
1818
private
1919

2020
def handle_auth(kind)
21-
return unless user_signed_in?
22-
23-
flash[:success] = t 'devise_omniauth_callbacks.success', kind: if is_navigational_format?
24-
redirect_to edit_user_registration_path
25-
else
26-
flash[:alert] = t 'devise_omniauth_callbacks.failure', kind:, reason: "#{auth.info.email} is not authorized"
27-
redirect_to new_user_registration_path
28-
end
21+
if user.present?
22+
flash[:success] = t 'devise_omniauth_callbacks.success', kind: kind if is_navigational_format?
23+
sign_in_and_redirect user, event: :authentication
24+
redirect_to edit_user_registration_path
25+
else
26+
flash[:alert] =
27+
t 'devise_omniauth_callbacks.failure', kind:, reason: "#{auth.info.email} is not authorized"
28+
redirect_to new_user_registration_path
29+
end
2930
end
3031

3132
def auth

0 commit comments

Comments
 (0)