java - Check permissions in all the URIs imported from a module in Play -
I'm writing Play 2.3.2 application in Java. I use a module in which there are some routes for which my application is required. In my root file, I include them with the following statement:
-> / Recommendation / recommendations system Root
I need to check the permissions on all the URIs that start with / recommendation
if the user is authenticated, the request is executed Otherwise it is sent to the home page.
I already have an annotation applying the action to check permissions.
How can I
You can possibly do everything Global request and check whether authentication is required for specific resources.
Import play.GlobalSettings; Import play.libs.F; Import play.mvc.Action; Import play.mv.Http; Import play.mvc.Result; Import java.lang.reflect.Method; Public class Global Global Assets {@ Override Expands Public Action Online (HTP Request Request, Method Action Method) {if (request.path ()) starts ("/ recommendation") & amp; Do not anticipate ()) [New action back. () {@ Override Public F. Promotions & lt; Results & gt; Calls (HTTP reference references) throws throwsable {Return f. Promojeur (redirect ("/")); }}; } Return super.onRequest (request, verb method); } Private boolean is not authenticated () {// return your certification check logic here; }}
Comments
Post a Comment