-
👋 Hello! I followed the Omniauth guide for my React/Rails application (the client is its own repository, I am not using I have the # app/controllres/rodauth_controller.rb
class RodauthController < ApplicationController
def omniauth
auth = request.env["omniauth.auth"]
# attempt to find existing identity directly
identity = AccountIdentity.find_by(provider: auth["provider"], uid: auth["uid"])
if identity
# update any external info changes
identity.update!(info: auth["info"])
# set account from identity
account = identity.account
end
# attempt to find an existing account by email
account ||= Account.find_by(email: auth["info"]["email"])
# disallow login if account is not verified
if account && account.status != rodauth.account_open_status_value
redirect_to rodauth.login_path, alert: rodauth.unverified_account_message
return
end
# create new account if it doesn't exist
unless account
account = Account.create!(email: auth["info"]["email"], status: rodauth.account_open_status_value)
end
# create new identity if it doesn't exist
unless identity
account.identities.create!(provider: auth["provider"], uid: auth["uid"], info: auth["info"])
end
# load the account into the rodauth instance
rodauth.account_from_login(account.email)
rodauth_response do # ensures any `after_action` callbacks get called
# sign in the loaded account
rodauth.login("omniauth")
end
end
end When I go through my flow, rather than be redirected to my JSON API, which gives me the correct GET response:
I tried to add an after_action that redirects to my client app, that gives me this error:
Is there a way I can replace the render from Rodauth, and instead redirect, such as via some |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
What code did you use for this? |
Beta Was this translation helpful? Give feedback.
What code did you use for this?