Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

109 řádky
4.1KB

  1. <%
  2. Class RequestOrderController_Class
  3. Private m_useLayout
  4. Private m_title
  5. Private Sub Class_Initialize()
  6. m_useLayout = True
  7. m_title = "Request an Order"
  8. End Sub
  9. Public Property Get useLayout
  10. useLayout = m_useLayout
  11. End Property
  12. Public Property Let useLayout(v)
  13. m_useLayout = v
  14. End Property
  15. Public Property Get Title
  16. Title = m_title
  17. End Property
  18. Public Property Let Title(v)
  19. m_title = v
  20. End Property
  21. '-------------------------------------------------------------------------------------------------------------------
  22. ' GET: show the "request an order" form (email + jurisdiction number)
  23. '-------------------------------------------------------------------------------------------------------------------
  24. Public Sub Index()
  25. Dim formValues, emailValue, jurisdictionValue, csrfToken, turnstileSiteKey
  26. Set formValues = FormCache().DeserializeForm("RequestOrder")
  27. FormCache().ClearForm "RequestOrder"
  28. emailValue = ""
  29. jurisdictionValue = ""
  30. If Not (formValues Is Nothing) Then
  31. If formValues.Exists("Email") Then emailValue = formValues("Email")
  32. If formValues.Exists("JurisdictionNumber") Then jurisdictionValue = formValues("JurisdictionNumber")
  33. End If
  34. csrfToken = HTMLSecurity().GetAntiCSRFToken("RequestOrder")
  35. turnstileSiteKey = GetAppSetting("TurnstileSiteKey")
  36. %>
  37. <!--#include file="../views/RequestOrder/index.asp" -->
  38. <%
  39. End Sub
  40. '-------------------------------------------------------------------------------------------------------------------
  41. ' POST: validate submission, create the order record, email a continuation link
  42. '-------------------------------------------------------------------------------------------------------------------
  43. Public Sub Create()
  44. MVC.RequirePost
  45. Dim csrfToken : csrfToken = Request.Form("csrf_token")
  46. If Not HTMLSecurity().IsValidAntiCSRFToken("RequestOrder", csrfToken) Then
  47. HTMLSecurity().ClearAntiCSRFToken "RequestOrder"
  48. Flash().AddError "Your form session expired. Please try again."
  49. Response.Redirect Routes().AppURL & "request-order"
  50. Exit Sub
  51. End If
  52. HTMLSecurity().ClearAntiCSRFToken "RequestOrder"
  53. Dim email, jurisdictionNumber
  54. email = Trim(Request.Form("Email"))
  55. jurisdictionNumber = Trim(Request.Form("JurisdictionNumber"))
  56. Dim errorList() : ReDim errorList(-1)
  57. If Not IsValidEmail(email) Then AddValidationError errorList, "Please enter a valid email address."
  58. If Len(jurisdictionNumber) = 0 Then
  59. AddValidationError errorList, "Please enter your jurisdiction number."
  60. ElseIf Not IsValidJurisdictionNumber(jurisdictionNumber) Then
  61. AddValidationError errorList, "That jurisdiction number could not be verified."
  62. End If
  63. Dim turnstileToken : turnstileToken = Request.Form("cf-turnstile-response")
  64. If Not VerifyTurnstileToken(turnstileToken, Request.ServerVariables("REMOTE_ADDR")) Then
  65. AddValidationError errorList, "Please complete the verification challenge."
  66. End If
  67. If UBound(errorList) >= 0 Then
  68. Dim i
  69. For i = 0 To UBound(errorList)
  70. Flash().AddError errorList(i)
  71. Next
  72. FormCache().SerializeForm "RequestOrder", Request.Form
  73. Response.Redirect Routes().AppURL & "request-order"
  74. Exit Sub
  75. End If
  76. Dim token : token = OrdersRepository().CreateOrder(email, jurisdictionNumber)
  77. OrderMailer().SendContinuationEmail email, token
  78. Flash().Success = "Check your email for a link to continue your order."
  79. Response.Redirect Routes().AppURL & "request-order"
  80. End Sub
  81. End Class
  82. Dim RequestOrderController_Class__Singleton
  83. Function RequestOrderController()
  84. If IsEmpty(RequestOrderController_Class__Singleton) Then
  85. Set RequestOrderController_Class__Singleton = New RequestOrderController_Class
  86. End If
  87. Set RequestOrderController = RequestOrderController_Class__Singleton
  88. End Function
  89. %>

Powered by TurnKey Linux.