grails - Restricting access to certain views - Beginner -


i have domain class , controller called person. controller has 4 views. create.gsp, remove.gsp, show.gsp, showdetail.gsp.

what want allows read permission showdetail.gsp viewers , restrict access create.gsp, remove.gsp , show.gsp views. administrator should able access these pages. how can in grails?

you can use security filters or can use spring security core grails plugin. if can want use security filters, can following:

  1. create session each user @ time of login. session["user"] = "rohit" // user name

  2. add security filters:

     personfilters(controller: 'person', action: 'create') {      before = {         // code change         if(!session["user"]) {       //flash.message = "your session has been expired. please login continue."             redirect(controller: "login", action:"index")             return false;        } else if(session["user"] && session["user"] != "admin"){            // redirect action            // redirect(controller: "", action:"index")            return false;        }     } } 

similarly, can add security filter actions don't want show user except admin.


Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -