Tyler Kocheff
03/07/2023, 2:52 PMsolidus_auth_devise
we would like to require users to confirm their email address if the order total is below a certain amount before they can check out as a fraud prevention measure (lots of fraudulent orders on the cheapest items in the store). We have this part working with some monkey patching, but noticed if the user registers an account during check out, once they confirm and log in, their cart is not associated, so they login to an empty cart.
Found the setting allow_unconfirmed_access_for
which does let the cart associate but then allows the user to check out without confirming their email first. Is there any way to associate the cart immediately upon account creation without letting a user check out while unconfirmed? Or maybe block checkout from fully completing if the user hasn't confirmed their email yet? My initial thought is that maybe the latter might be easier to implement.
I found some of the logic in the warden
and devise
gem, but wondering if anyone has worked this out already or if there's a different setting I'm missing.
Edit: Maybe this actually isn't working. I can't reproduce it in the normal checkout flow, but after deploying this yesterday, somehow over 12 guest orders have still come through that should have been forced to register. Not sure if there's some other way these might be coming in? Hoping anyone has any insight.
Edit 2 (sorry): Looks like the method I took is only blocking the frontend form from appearing, so hitting the /checkout/registration
endpoint with a valid auth token and the email field filled out still allows a user to guest checkout. Not sure if we did this wrong or if this is a bug.Joren Rapini
03/08/2023, 2:21 PMkennyadsl
kennyadsl
Tyler Kocheff
03/08/2023, 2:36 PMsolidus_paypal_braintree
gemTyler Kocheff
03/08/2023, 2:37 PMJoren Rapini
03/08/2023, 2:40 PMJoren Rapini
03/08/2023, 2:40 PMkennyadsl
to add some sort of backend check that prevents a user from placing a low $$ order if they’re not signed in with a validated accountI think you can do that with a new before_transition in the order state machine: https://github.com/solidusio/solidus/blob/c09ead361b6b705897bf6a05aa38cef24d7d3c0d/core/lib/spree/core/state_machines/order.rb#LL114C60-L114C60
Tyler Kocheff
03/08/2023, 4:31 PMrequire_registration
but haven't found anything that actually works (think I grabbed this from another method).kennyadsl
kennyadsl
Tyler Kocheff
03/08/2023, 4:38 PMerrors
but when I exit the pry, it just moves on to the address step anyways. Are errors
the condition that should prevent it from moving forward in the state machine?kennyadsl
Tyler Kocheff
03/08/2023, 4:39 PMkennyadsl
kennyadsl
&& (return false)
? Did you try to move it on a new line?Tyler Kocheff
03/08/2023, 4:43 PMTyler Kocheff
03/08/2023, 4:52 PMkennyadsl
kennyadsl
kennyadsl
Tyler Kocheff
03/08/2023, 5:04 PMkennyadsl
Tyler Kocheff
03/08/2023, 5:05 PMbase.state_machine.before_transition to: :confirm
and it threw me back to the delivery step when I tried to continue.Tyler Kocheff
03/08/2023, 5:05 PMkennyadsl
order.next
Tyler Kocheff
03/08/2023, 5:10 PMkennyadsl
order.go_to_state(:address)
.kennyadsl
Tyler Kocheff
03/08/2023, 5:16 PMTyler Kocheff
03/08/2023, 5:17 PMkennyadsl
Tyler Kocheff
03/08/2023, 8:16 PMJoren Rapini
03/09/2023, 10:09 PMJoren Rapini
03/09/2023, 10:35 PMChris Todorov
03/09/2023, 11:18 PMJoren Rapini
03/10/2023, 1:31 PMkennyadsl
Chris Todorov
03/10/2023, 6:04 PMJoren Rapini
03/10/2023, 7:40 PMJoren Rapini
03/10/2023, 8:29 PMJoren Rapini
03/10/2023, 8:51 PM