Reputation: 187
I want to set a rule for accessing a route to some users that I created. My user model is :
public class User extends Model{
public String firstName;
@Required
public String lastName;
@Required
public String password;
@Required
public boolean labAccess;
public boolean labAccess() {
return labAccess;
}
}
After users log in to the main page, I have a route link to the "Laboratory page". I want to set a rule for users: if the labAccess of User is true he/she can click the route to see the laboratory page.
My controller action is like this :
public class Application extends Controller {
public static Result login() {
return ok(login.render(form(Login.class)));
}
public static Result laboratory() {
return ok(laboratoryPage.render("hello. welcome to lab));
}
}
How to set this rule? Do I need to save something in session or set some constraint on actions in my Application class?
Upvotes: 0
Views: 51
Reputation: 10404
You will have to use Action Composition. Checkout the official documentation!
Upvotes: 2