[Cppcms-users] How can we have a functionality similar to Filters (in JavaEE) or Hooks (as in PHP's
Brought to you by:
artyom-beilis
|
From: Abhishek K. <abh...@gm...> - 2014-07-10 10:45:32
|
Hi,
I am working on an application and have a very simple requirement.
Its just that I want all the requests being made to the server should pass
an authentication criteria.
If the requests are valid (based on session checks), let them continue or
else redirect them to a login page.
I have created one such implementation as shown here:
void main_controller::manage_default(std::string page) {
if(page == "/login") {
if(session().is_set("username")) {
response().status(cppcms::http::response::found,url(""));
}
} else {
if(!session().is_set("username")) {
response().status(cppcms::http::response::found,url("/login"));
}
}
}
but this function (manage_default) is mapped to default url (i.e. ""). So it
won't be called if user calls some other pages like /view_bills (without
touching the base url).
So is there a way where I can capture all such requests at a single place
and then allow such requests to continue further?
Regards,
Abhishek
|