Modify base_url or _email_link generation on a per action basis #278
-
I'm handling some callback routes or email links on different hosts depending on the action, as I'm going for a progressive implementation of the library. I want to keep the generated rails view, while creating my custom auth flow on a new host vía JSON API. Is there a way to modify I've tried this and a few other overrides on # rodauth_main.rb
def verify_account_email_link
"#{ENV.fetch("FRONTEND_APP_URL", "http://localhost:3001")}/auth/verify-account?#{verify_account_key_param}=#{verify_account_key_value}"
end |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 8 replies
-
That method definition should be overriding the email link. In your mailer, when you look at |
Beta Was this translation helpful? Give feedback.
Since there are no validation errors, this most likely means the token was invalid. You can verify that by setting error reason in the JSON response, then checking if it matches
invalid_verify_account_key
.The reason it's invalid is because rodauth-rails configures Rodauth to use HMACs, which requires hashed tokens to be passed to email links, and you're passing the raw token. That's why overriding
base_url
was working for you, because it wasn't changing the token. So, it's have to be