Loading src/auth.cpp +22 −16 Changes for src/auth.cpp: 22 added lines, 16 removed lines. Original line number Diff line number Diff line Loading @@ -39,6 +39,10 @@ #include "theme.h" #include "session.h" namespace blogi { const authdb::uuid emptyuuid; }; blogi::Auth::Auth(dbpp::Database **pcon,blogi::Config *cfg){ _dbconn=pcon; _config=cfg; Loading @@ -54,15 +58,6 @@ blogi::Auth::Auth(dbpp::Database **pcon,blogi::Config *cfg){ << "password character varying(255)" << ");"; _dbconn[0]->exec(sql,res); _AuthCon.setUrl(_config->getAuthUrl()); _AuthCon.setClientName(_config->getClientName()); _AuthCon.setClientSecret(_config->getClientSecret()); authdb::client::Client clt(_AuthCon); clt.ClientAuth(); } blogi::Auth::~Auth(){ Loading @@ -70,21 +65,28 @@ blogi::Auth::~Auth(){ } 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); authdb::client::ClientConnection authcon; authcon.setClientName(_config->getClientName()); authcon.setClientSecret(_config->getClientSecret()); authdb::client::Client clt(authcon); if(!clt.ClientAuth()) return emptyuuid; authcon.setUsername(username); authcon.setUserPassword(password); bool ret = clt.UserAuth(); Session sess(_dbconn[tid]); ret=clt.GPOcheck("e7d3b8b3-4825-11f0-ae2b-3cecefce9cb6"); if(ret){ sess.addSessionData(ssid,"authid",_AuthCon.getSessionID().c_str()); sess.addSessionData(ssid,"authid",authcon.getSessionID().c_str()); class authdb::SessionData sdat; clt.SessionInfo(sdat); authdb::uuid uid; sdat.getUid(uid); sess.addSessionData(ssid,"uid",uid.c_str()); } return _AuthCon.getSessionID(); return authcon.getSessionID(); } bool blogi::Auth::isLoggedIn(const int tid,libhttppp::HttpRequest *curreq,const char *ssid){ Loading @@ -104,9 +106,13 @@ bool blogi::Auth::isLoggedIn(const int tid,libhttppp::HttpRequest *curreq,const if(sessid.empty()) return false; _AuthCon.setSessionID(sessid); authdb::client::ClientConnection authcon; authcon.setUrl( _config->getAuthUrl()); authcon.setClientName(_config->getClientName()); authcon.setClientSecret(_config->getClientSecret()); authcon.setSessionID(sessid); authdb::client::Client clt(_AuthCon); authdb::client::Client clt(authcon); if(clt.GPOcheck("e7d3b8b3-4825-11f0-ae2b-3cecefce9cb6")){ return true; } Loading src/auth.h −1 Changes for src/auth.h: 0 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -50,7 +50,6 @@ namespace blogi { 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; dbpp::Database **_dbconn; blogi::Config *_config; Loading Loading
src/auth.cpp +22 −16 Changes for src/auth.cpp: 22 added lines, 16 removed lines. Original line number Diff line number Diff line Loading @@ -39,6 +39,10 @@ #include "theme.h" #include "session.h" namespace blogi { const authdb::uuid emptyuuid; }; blogi::Auth::Auth(dbpp::Database **pcon,blogi::Config *cfg){ _dbconn=pcon; _config=cfg; Loading @@ -54,15 +58,6 @@ blogi::Auth::Auth(dbpp::Database **pcon,blogi::Config *cfg){ << "password character varying(255)" << ");"; _dbconn[0]->exec(sql,res); _AuthCon.setUrl(_config->getAuthUrl()); _AuthCon.setClientName(_config->getClientName()); _AuthCon.setClientSecret(_config->getClientSecret()); authdb::client::Client clt(_AuthCon); clt.ClientAuth(); } blogi::Auth::~Auth(){ Loading @@ -70,21 +65,28 @@ blogi::Auth::~Auth(){ } 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); authdb::client::ClientConnection authcon; authcon.setClientName(_config->getClientName()); authcon.setClientSecret(_config->getClientSecret()); authdb::client::Client clt(authcon); if(!clt.ClientAuth()) return emptyuuid; authcon.setUsername(username); authcon.setUserPassword(password); bool ret = clt.UserAuth(); Session sess(_dbconn[tid]); ret=clt.GPOcheck("e7d3b8b3-4825-11f0-ae2b-3cecefce9cb6"); if(ret){ sess.addSessionData(ssid,"authid",_AuthCon.getSessionID().c_str()); sess.addSessionData(ssid,"authid",authcon.getSessionID().c_str()); class authdb::SessionData sdat; clt.SessionInfo(sdat); authdb::uuid uid; sdat.getUid(uid); sess.addSessionData(ssid,"uid",uid.c_str()); } return _AuthCon.getSessionID(); return authcon.getSessionID(); } bool blogi::Auth::isLoggedIn(const int tid,libhttppp::HttpRequest *curreq,const char *ssid){ Loading @@ -104,9 +106,13 @@ bool blogi::Auth::isLoggedIn(const int tid,libhttppp::HttpRequest *curreq,const if(sessid.empty()) return false; _AuthCon.setSessionID(sessid); authdb::client::ClientConnection authcon; authcon.setUrl( _config->getAuthUrl()); authcon.setClientName(_config->getClientName()); authcon.setClientSecret(_config->getClientSecret()); authcon.setSessionID(sessid); authdb::client::Client clt(_AuthCon); authdb::client::Client clt(authcon); if(clt.GPOcheck("e7d3b8b3-4825-11f0-ae2b-3cecefce9cb6")){ return true; } Loading
src/auth.h −1 Changes for src/auth.h: 0 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -50,7 +50,6 @@ namespace blogi { 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; dbpp::Database **_dbconn; blogi::Config *_config; Loading