Loading src/auth.cpp +19 −6 Changes for src/auth.cpp: 19 added lines, 6 removed lines. Original line number Diff line number Diff line Loading @@ -69,7 +69,7 @@ blogi::Auth::~Auth(){ } bool blogi::Auth::login(const int tid,const char* username, const char* password, const char *ssid){ const authdb::uuid &blogi::Auth::login(const int tid,const char* username, const char* password, const char *ssid){ authdb::client::Client clt(_AuthCon); _AuthCon.setUsername(username); _AuthCon.setUserPassword(password); Loading @@ -84,15 +84,28 @@ bool blogi::Auth::login(const int tid,const char* username, const char* password sdat.getUid(uid); sess.addSessionData(ssid,"uid",uid.c_str()); } return ret; return _AuthCon.getSessionID(); } bool blogi::Auth::isLoggedIn(const int tid,libhttppp::HttpRequest *curreq,const char *ssid){ try{ std::string storeid; Session sess(_dbconn[tid]); sess.getSessionData(ssid,"authid",storeid); _AuthCon.setSessionID(storeid.c_str()); libhttppp::HttpCookie cook; cook.parse(curreq); authdb::uuid sessid; for(libhttppp::HttpCookie::CookieData *curcook=cook.getfirstCookieData(); curcook; curcook=curcook->nextCookieData()){ if(strcmp(curcook->getKey(),"authid")==0){ sessid=curcook->getValue(); } } if(sessid.empty()) return false; _AuthCon.setSessionID(sessid); authdb::client::Client clt(_AuthCon); if(clt.GPOcheck("e7d3b8b3-4825-11f0-ae2b-3cecefce9cb6")){ return true; Loading src/auth.h +3 −1 Changes for src/auth.h: 3 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -34,6 +34,8 @@ #include <dbpp/database.h> #include <authdb/uuid.h> #include "session.h" #include "conf.h" Loading @@ -45,7 +47,7 @@ namespace blogi { public: Auth(dbpp::Database **pcon,blogi::Config *cfg); ~Auth(); bool login(const int tid,const char *username,const char *password,const char *ssid); const authdb::uuid &login(const int tid,const char *username,const char *password,const char *ssid); bool isLoggedIn(const int tid,libhttppp::HttpRequest *curreq,const char *ssid); private: authdb::client::ClientConnection _AuthCon; Loading src/blogi.cpp +8 −1 Changes for src/blogi.cpp: 8 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -205,8 +205,15 @@ void blogi::Blogi::loginPage(libhttppp::HttpRequest *curreq,const int tid,const curres.send(curreq,out.c_str(),out.size()); return; } if(PlgArgs->auth->login(tid,username.c_str(),password.c_str(),sessionid)){ authdb::uuid sessid; sessid=PlgArgs->auth->login(tid,username.c_str(),password.c_str(),sessionid); if(!sessid.empty()){ libhttppp::HttpResponse curres; libhttppp::HttpCookie authid; authid.setcookie(&curres,"authid",sessid.c_str()); curres.setState(HTTP307); curres.setVersion(HTTPVERSION(1.1)); curres.setHeaderData("Location")->push_back(PlgArgs->config->getstartpage()); Loading Loading
src/auth.cpp +19 −6 Changes for src/auth.cpp: 19 added lines, 6 removed lines. Original line number Diff line number Diff line Loading @@ -69,7 +69,7 @@ blogi::Auth::~Auth(){ } bool blogi::Auth::login(const int tid,const char* username, const char* password, const char *ssid){ const authdb::uuid &blogi::Auth::login(const int tid,const char* username, const char* password, const char *ssid){ authdb::client::Client clt(_AuthCon); _AuthCon.setUsername(username); _AuthCon.setUserPassword(password); Loading @@ -84,15 +84,28 @@ bool blogi::Auth::login(const int tid,const char* username, const char* password sdat.getUid(uid); sess.addSessionData(ssid,"uid",uid.c_str()); } return ret; return _AuthCon.getSessionID(); } bool blogi::Auth::isLoggedIn(const int tid,libhttppp::HttpRequest *curreq,const char *ssid){ try{ std::string storeid; Session sess(_dbconn[tid]); sess.getSessionData(ssid,"authid",storeid); _AuthCon.setSessionID(storeid.c_str()); libhttppp::HttpCookie cook; cook.parse(curreq); authdb::uuid sessid; for(libhttppp::HttpCookie::CookieData *curcook=cook.getfirstCookieData(); curcook; curcook=curcook->nextCookieData()){ if(strcmp(curcook->getKey(),"authid")==0){ sessid=curcook->getValue(); } } if(sessid.empty()) return false; _AuthCon.setSessionID(sessid); authdb::client::Client clt(_AuthCon); if(clt.GPOcheck("e7d3b8b3-4825-11f0-ae2b-3cecefce9cb6")){ return true; Loading
src/auth.h +3 −1 Changes for src/auth.h: 3 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -34,6 +34,8 @@ #include <dbpp/database.h> #include <authdb/uuid.h> #include "session.h" #include "conf.h" Loading @@ -45,7 +47,7 @@ namespace blogi { public: Auth(dbpp::Database **pcon,blogi::Config *cfg); ~Auth(); bool login(const int tid,const char *username,const char *password,const char *ssid); const authdb::uuid &login(const int tid,const char *username,const char *password,const char *ssid); bool isLoggedIn(const int tid,libhttppp::HttpRequest *curreq,const char *ssid); private: authdb::client::ClientConnection _AuthCon; Loading
src/blogi.cpp +8 −1 Changes for src/blogi.cpp: 8 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -205,8 +205,15 @@ void blogi::Blogi::loginPage(libhttppp::HttpRequest *curreq,const int tid,const curres.send(curreq,out.c_str(),out.size()); return; } if(PlgArgs->auth->login(tid,username.c_str(),password.c_str(),sessionid)){ authdb::uuid sessid; sessid=PlgArgs->auth->login(tid,username.c_str(),password.c_str(),sessionid); if(!sessid.empty()){ libhttppp::HttpResponse curres; libhttppp::HttpCookie authid; authid.setcookie(&curres,"authid",sessid.c_str()); curres.setState(HTTP307); curres.setVersion(HTTPVERSION(1.1)); curres.setHeaderData("Location")->push_back(PlgArgs->config->getstartpage()); Loading