GET: /registration -> display form: "PLease put email into URL query" without validation
GET: /registration?email=test@valid.com -> if email valid send registartion link and redirect to registration/thank-you
GET: /registration?email=invalid -> if email invalid display error: "Given email is invalid. Please put correct email in URL query"
/registration/accept:
GET: /registration/accept?email=test@valid.com.invalid-signature -> display error about invalid signature
GET: /registration/accept?email=test@valid.com.valid-signature -> ask for passwords (empty form)
GET: /registration/accept?email=test@valid.com.valid-signature&password1=password&password2=different -> display error about inconsistent passwords
GET: /registration/accept?email=test@valid.com.valid-signature&password1=same&password2=same -> redirect to /login?message=Thanks you have been registered successfully
/login stub:
GET: /login -> display "please login" and optionally message ....
Routing duplex
Let's start with well typed routes - something like (this has been written without second thought so please modify it as you want :-):
newtype Email = Email String
data Route
= Login String
| Registration Email
-- | `These` for two passwords
| RegistrationAccept Email (Maybe (These String String))
/registration:
GET: /registration -> display form: "PLease put email into URL query" without validation GET: /registration?email=test@valid.com -> if email valid send registartion link and redirect to registration/thank-you GET: /registration?email=invalid -> if email invalid display error: "Given email is invalid. Please put correct email in URL query"
/registration/accept:
GET: /registration/accept?email=test@valid.com.invalid-signature -> display error about invalid signature GET: /registration/accept?email=test@valid.com.valid-signature -> ask for passwords (empty form) GET: /registration/accept?email=test@valid.com.valid-signature&password1=password&password2=different -> display error about inconsistent passwords GET: /registration/accept?email=test@valid.com.valid-signature&password1=same&password2=same -> redirect to /login?message=Thanks you have been registered successfully
/login stub:
GET: /login -> display "please login" and optionally message ....
Let's start with well typed routes - something like (this has been written without second thought so please modify it as you want :-):
A lot of route examples are here: https://github.com/paluh/magusai/tree/master/src/Route
Please don't hesitate to ask if you have some question related to routing duplex :-)