mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-05 22:26:07 +00:00
Handle user confirmation with turbo stream
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
= turbo_stream.update "#{params[:tab] || 'forgot'}-feedback" do
|
||||
= render partial: 'shared/flashes', locals: { flashes: flash }
|
||||
@@ -1,8 +1,7 @@
|
||||
import { Controller } from "stimulus";
|
||||
|
||||
export default class extends Controller {
|
||||
static targets = ["background", "modal", "email"];
|
||||
static values = { email: String };
|
||||
static targets = ["background", "modal"];
|
||||
|
||||
connect() {
|
||||
if (this.hasModalTarget) {
|
||||
@@ -19,13 +18,6 @@ export default class extends Controller {
|
||||
window.dispatchEvent(new Event("login:modal:open"));
|
||||
}
|
||||
|
||||
emailOnInput(event) {
|
||||
this.emailValue = event.currentTarget.value;
|
||||
this.emailTargets.forEach((element) => {
|
||||
element.value = this.emailValue;
|
||||
});
|
||||
}
|
||||
|
||||
open = () => {
|
||||
if (!location.hash.substr(1).includes("/login")) {
|
||||
history.pushState({}, "", "#/login");
|
||||
@@ -57,19 +49,6 @@ export default class extends Controller {
|
||||
}, 200);
|
||||
}
|
||||
|
||||
resend_confirmation(event) {
|
||||
fetch("/user/spree_user/confirmation", {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
spree_user: { email: this.emailValue },
|
||||
tab: event.currentTarget.dataset.tab,
|
||||
}),
|
||||
headers: { "Content-type": "application/json; charset=UTF-8" },
|
||||
})
|
||||
.then((data) => data.json())
|
||||
.then(CableReady.perform);
|
||||
}
|
||||
|
||||
returnHome() {
|
||||
window.location = "/";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user