summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2018-03-03 19:44:17 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2018-03-03 19:44:17 +0000
commit301e91385745647e113ee86e09500ef76f0dfad2 (patch)
tree7f1ccb49d7d3c5d85d11c538226d94db2d469e29
parentFix incorrect mask number on package version list by simply including the set... (diff)
downloadgentoobrowse-2.0.2.tar.bz2
gentoobrowse-2.0.2.tar.xz
gentoobrowse-2.0.2.zip
Add a route that works with the signup emailgentoobrowse-2.0.2
-rw-r--r--gentoobrowse/src/test.cpp2
-rw-r--r--gentoobrowse/src/user.cpp62
2 files changed, 52 insertions, 12 deletions
diff --git a/gentoobrowse/src/test.cpp b/gentoobrowse/src/test.cpp
index 79d3d42..cd613ff 100644
--- a/gentoobrowse/src/test.cpp
+++ b/gentoobrowse/src/test.cpp
@@ -111,7 +111,7 @@ BOOST_FIXTURE_TEST_SUITE(ta, CoreWithDefaultRouter);
BOOST_AUTO_TEST_CASE( endpointCount )
{
- BOOST_REQUIRE_EQUAL(24, AdHoc::PluginManager::getDefault()->getAll<IceSpider::RouteHandlerFactory>().size());
+ BOOST_REQUIRE_EQUAL(25, AdHoc::PluginManager::getDefault()->getAll<IceSpider::RouteHandlerFactory>().size());
BOOST_REQUIRE_EQUAL(5, routes.size());
}
diff --git a/gentoobrowse/src/user.cpp b/gentoobrowse/src/user.cpp
index 27d49d4..e98de2c 100644
--- a/gentoobrowse/src/user.cpp
+++ b/gentoobrowse/src/user.cpp
@@ -105,14 +105,36 @@ namespace GentooBrowse {
IceSpider::XsltStreamSerializer::IceSpiderFactory _serializer_text_html;
};
+ class verificationHandler {
+ protected:
+ verificationHandler(const IceSpider::Core * core) :
+ prx0(core->getProxy<IceSpider::SessionManager>()),
+ prx1(core->getProxy<Gentoo::Users>())
+ {
+ }
+
+ void execute(IceSpider::IHttpRequest * request, const std::string & _p_username, const std::string & _p_guid) const
+ {
+ auto user = prx1->verify(_p_username, _p_guid, request->getContext());
+ auto s = prx0->createSession();
+ s->variables[USERID] = boost::lexical_cast<std::string>(user->userid);
+ prx0->updateSession(s);
+ request->setCookie(SESSIONID, s->id, IceUtil::None, "/");
+ request->responseRedirect("/user/home", "Verified, welcome!");
+ }
+
+ private:
+ const IceSpider::SessionManagerPrx prx0;
+ const Gentoo::UsersPrx prx1;
+ };
+
// Route name: verification post
// path: /user/verification
- class verificationPost : public IceSpider::IRouteHandler {
+ class verificationPost : public IceSpider::IRouteHandler, verificationHandler {
public:
verificationPost(const IceSpider::Core * core) :
IceSpider::IRouteHandler(IceSpider::HttpMethod::POST, "/user/verification"),
- prx0(core->getProxy<IceSpider::SessionManager>()),
- prx1(core->getProxy<Gentoo::Users>()),
+ verificationHandler(core),
_pn_username("username"),
_pn_guid("guid")
{
@@ -125,21 +147,38 @@ namespace GentooBrowse {
[this]() { return requiredParameterNotFound<::std::string>("Body", _pn_username); });
auto _p_guid(request->getBodyParam<::std::string>(_pbody, _pn_guid) /
[this]() { return requiredParameterNotFound<::std::string>("Body", _pn_guid); });
- auto user = prx1->verify(_p_username, _p_guid, request->getContext());
- auto s = prx0->createSession();
- s->variables[USERID] = boost::lexical_cast<std::string>(user->userid);
- prx0->updateSession(s);
- request->setCookie(SESSIONID, s->id, IceUtil::None, "/");
- request->responseRedirect("/user/home", "Verified, welcome!");
+ verificationHandler::execute(request, _p_username, _p_guid);
}
private:
- const IceSpider::SessionManagerPrx prx0;
- const Gentoo::UsersPrx prx1;
const std::string _pn_username;
const std::string _pn_guid;
};
+ // Route name: verification post
+ // path: /user/verification/{guid}/{username}
+ class verificationGet : public IceSpider::IRouteHandler, verificationHandler {
+ public:
+ verificationGet(const IceSpider::Core * core) :
+ IceSpider::IRouteHandler(IceSpider::HttpMethod::GET, "/user/verification/{guid}/{username}"),
+ verificationHandler(core),
+ _pi_guid(2),
+ _pi_username(3)
+ {
+ }
+
+ void execute(IceSpider::IHttpRequest * request) const
+ {
+ auto _p_guid(request->getURLParam<::std::string>(_pi_guid));
+ auto _p_username(request->getURLParam<::std::string>(_pi_username));
+ verificationHandler::execute(request, _p_username, _p_guid);
+ }
+
+ private:
+ const ::Ice::Int _pi_guid;
+ const ::Ice::Int _pi_username;
+ };
+
// Route name: home
// path: /user/home
class home : public IceSpider::IRouteHandler,
@@ -244,5 +283,6 @@ FACTORY(GentooBrowse::logout, IceSpider::RouteHandlerFactory);
FACTORY(GentooBrowse::signup, IceSpider::RouteHandlerFactory);
FACTORY(GentooBrowse::signupPost, IceSpider::RouteHandlerFactory);
FACTORY(GentooBrowse::verification, IceSpider::RouteHandlerFactory);
+FACTORY(GentooBrowse::verificationGet, IceSpider::RouteHandlerFactory);
FACTORY(GentooBrowse::verificationPost, IceSpider::RouteHandlerFactory);