Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

play framework how to do separate routing for same URL ?

I have built a site that when a user fills in a form correctly he is redirected to a confirmation page that has the url mySite.com\A\confirmation.

I want to be able to redirect the user to a different page If he enters that url "mySite.com\A\confirmation" himself

What is the best way of achieving this (i was hoping something more elegant then keeping state of each user)

like image 591
james Avatar asked Feb 24 '12 12:02

james


People also ask

In which folder does play expect routes file?

The answer to this question lies in the app/conf/routes configuration file. Play's router translates HTTP requests into action calls.

Which play component is in charge of mapping incoming request URL into action?

The router is the component in charge of translating incoming HTTP Requests into action calls (a static, public method of a Controller).

What are routes files?

The routing file is a VSAM key-sequenced data set that contains information to route each data set to its LPD printer queue. You need one routing file entry (VSAM record) for each printer being used at the installation.

What is routes scala?

The routes file syntax conf/routes is the configuration file used by the router. This file lists all of the routes needed by the application. Each route consists of an HTTP method and URI pattern, both associated with a call to an Action generator.


1 Answers

Possible simple solutions:

  1. Store some key in cookie, verify it on confirmation page and clear. Cookie value should be encrypted, so user won't be able to forge it (if not, you can use Crypto.encryptAES(String), Crypto.decryptAES(String) manually.
  2. Change confirmation controller to accept parameter, pass that parameter from form submit controller: confirmation(secureParameter); Validate parameter in confirmation method.
  3. Do POST request to confirmation from your code and change routes and redirect on GET requests
  4. Instead of redirect to confirmation in your controller, simply render confirmation template directly, this way there would be no confirmation URL.
like image 55
Alexander Ponomarenko Avatar answered Sep 28 '22 16:09

Alexander Ponomarenko