In my application authentication scheme is based on user and role. users with particular role have access to particular action method.
To implement this I have done following
1.Write custom action
public class Authorization extends play.mvc.Action.Simple {
public Promise<Result> call(Context ctx) throws Throwable {
//check access
return delegate.call(ctx);
}
}
2.Annotate controller with action
@With(actions.Authorization.class)
public class Upload extends Controller {
....
}
In my action I have access to user which is in session. I want to get current controller and action so that I can authenticate user. Is there any way to this?
I have read about creating custom annotation with params and in each controller pass parameters to identify the action. But it seems to much work and error prone if by mistake i write wrong action name while copy paste.
Thanks