mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-29 21:17:17 +00:00
Handle unconfirmed email message in UserSessionsController
This commit is contained in:
@@ -13,6 +13,7 @@ module Spree
|
||||
|
||||
helper 'spree/base'
|
||||
|
||||
prepend_before_action :handle_unconfirmed_email
|
||||
before_action :set_checkout_redirect, only: :create
|
||||
after_action :ensure_valid_locale_persisted, only: :create
|
||||
|
||||
@@ -49,6 +50,22 @@ module Spree
|
||||
Spree.t(:login)
|
||||
end
|
||||
|
||||
def handle_unconfirmed_email
|
||||
render_unconfirmed_response if email_unconfirmed?
|
||||
end
|
||||
|
||||
def email_unconfirmed?
|
||||
Spree::User.where(email: params.dig(:spree_user, :email), confirmed_at: nil).exists?
|
||||
end
|
||||
|
||||
def render_unconfirmed_response
|
||||
render status: :unprocessable_entity, operations: cable_car.inner_html(
|
||||
"#login-feedback",
|
||||
partial("layouts/alert",
|
||||
locals: { type: "alert", message: t(:email_unconfirmed), unconfirmed: true })
|
||||
)
|
||||
end
|
||||
|
||||
def ensure_valid_locale_persisted
|
||||
# When creating a new user session we have to wait until after a successful
|
||||
# login to be able to persist a selected locale on the current user
|
||||
|
||||
Reference in New Issue
Block a user