Check if a freelancer is logged in based on cookie data
This commit is contained in:
@ -279,4 +279,20 @@ namespace Utilities {
|
||||
pqxx::result result = Database::executeStatement_SELECT_FREELANCERS_WITHCOMMISSIONSSTATE(databaseConnection);
|
||||
return Database::convertResultToJSON(result, "freelancerProfiles");
|
||||
}
|
||||
|
||||
/*
|
||||
* Checks if freelancer is logged in
|
||||
* Takes config, the loginkey and freelancerid taken from the secure cookie
|
||||
* returns true if logged in
|
||||
*/
|
||||
bool checkFreelancerLoginState(const Utilities::config& configuration, const std::string& loginKey, const std::string& freelancerEmail) {
|
||||
bool loggedIn = false;
|
||||
//check if freelancer exists
|
||||
pqxx::connection databaseConnection(configuration.databaseConnectionString);
|
||||
pqxx::result checkLoginKey = Database::executePreparedStatement_SELECT_CHECK_FREELANCER_LOGIN_STATE(databaseConnection, freelancerEmail, loginKey);
|
||||
int checkLoginKeyExtracted = std::stoi(checkLoginKey.at(0).at(0).c_str());
|
||||
if (checkLoginKeyExtracted == 1)
|
||||
loggedIn = true;
|
||||
return loggedIn;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user