Handle user confirmation responses with turbo_stream

This commit is contained in:
wandji20
2024-10-13 00:56:58 +01:00
parent fad4ae49f5
commit 29534dbec4
3 changed files with 6 additions and 8 deletions

View File

@@ -3,7 +3,6 @@
class UserConfirmationsController < DeviseController
# Needed for access to current_ability, so we can authorize! actions
include Spree::Core::ControllerHelpers::Auth
include CablecarResponses
# GET /resource/confirmation?confirmation_token=abcdef
def show
@@ -29,11 +28,8 @@ class UserConfirmationsController < DeviseController
set_flash_message(:error, :confirmation_not_sent)
end
else
render cable_ready: cable_car.inner_html(
"##{params[:tab] || 'forgot'}-feedback",
partial("layouts/alert",
locals: { type: "success", message: t("devise.confirmations.send_instructions") })
)
flash.now[:sucess] = t("devise.confirmations.send_instructions")
render 'spree/user_confirmations/create'
return
end

View File

@@ -0,0 +1,2 @@
= turbo_stream.update "#{params[:tab] || 'forgot'}-feedback" do
= render partial: 'shared/flashes', locals: { flashes: flash }

View File

@@ -75,8 +75,8 @@ export default class extends Controller {
}),
headers: { "Content-type": "application/json; charset=UTF-8" },
})
.then((data) => data.json())
.then(CableReady.perform);
.then(response => response.text())
.then(html => {console.log(html); Turbo.renderStreamMessage(html)});
}
returnHome() {