Allow prev from mail-in registration

Stephen Paul Weber created

Change summary

lib/registration.rb | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)

Detailed changes

lib/registration.rb 🔗

@@ -399,7 +399,9 @@ class Registration
 		class Mail
 			Payment.kinds[:mail] = method(:new)
 
-			def initialize(_customer, _tel, final_message: nil, **)
+			def initialize(customer, tel, final_message: nil, **)
+				@customer = customer
+				@tel = tel
 				@final_message = final_message
 			end
 
@@ -425,9 +427,15 @@ class Registration
 			end
 
 			def write
-				Command.finish(status: :canceled) do |reply|
+				Command.reply { |reply|
+					reply.allowed_actions = [:prev]
+					reply.status = :canceled
 					reply.command << form
-				end
+				}.then { |iq|
+					raise "Action not allowed" unless iq.prev?
+
+					Activation.for(@customer, @tel).then(&:write)
+				}
 			end
 		end
 	end