Closed gruschis closed 2 years ago
Thanks for reporting, it should indeed work without generating the template, I'll look into it. You didn't by any chance change layout settings in your RodauthController
?
No. Here's the controller
# app/controllers/rodauth_controller.rb
class RodauthController < ApplicationController
# used by Rodauth for rendering views, CSRF protection, and running any
# registered action callbacks and rescue_from handlers
def download_recovery_codes
send_data rodauth.recovery_codes.join("\n"),
filename: 'myapp-recovery-codes.txt',
type: 'text/plain'
end
end
I'm not able to reproduce the error with a fresh Rails 6.1 app. I've generated views for otp
, sms_codes
, and recovery_codes
, and tried changing the login to the current email address, but I get the form back with the validation error saying that the new email is the same as the current email.
It would be helpful to get a Rails app that reproduces the issue, but even the backtrace might helpful.
Here's the repo: https://github.com/gruschis/argument-error
Please note, that this case was not a fresh install.
I had added a couple of gems, with attention to rails' new importmap.
When commenting out import "@hotwired/turbo-rails"
in the app/javascript/application.js
it doesn't throw the error.
I'm not certain if turbo or importmap is the culprit here.
I hope that helps.
/ edit: I also wanted to add that this issue might be out of scope here :)
Thanks for sharing, there is indeed some incompatibility with Turbo in rodauth-rails, specifically with Turbo sending the turbo stream MIME type in the Accept
request header. I'll work on a fix.
So, when Turbo sends a request, a controller will have configured its formats
to [:turbo_stream, :html]
, indicating that it can render both turbo_stream
and html
templates. This works with normal rendering, but when rodauth-rails uses render html: "..."
to render Rodauth's built-in templates, Rails takes only for first available format, which in this case is :turbo_stream
. It then tries to find a layout with turbo_stream
format, which causes the error. It seems that passing the :formats
option to render
should resolve the issue, I'll try that.
Hello Janko,
Getting this error after submitting the change_login form. The email address is the same as the currently used one. When using a different email address, it redirects to root and sends out the email to verify the change. Generating the views resolves the issue, though. Details below.
Rack Session
Local Variables
Instance Variables
I have some views generated. Listed below. Note that I haven't generated the change_login views yet.
Running
rails generate rodauth:views change_login
creates three more files.After that, it works as expected. It renders the form with the input and the error message (
invalid login, same as current login
)