Optimized check if a loggin session exists
This commit is contained in:
@ -424,4 +424,20 @@ namespace Utilities {
|
||||
std::string generateExpiredCookie() {
|
||||
return "EXPIRED; HttpOnly; Secure; Path=/; Max-Age=0";
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* checks if the given cookiecontext contains a valid logged in cookie
|
||||
* takes configuration and crow::CookieParser::context
|
||||
*/
|
||||
bool checkCookieLoginState(const Utilities::config& configuration, const crow::CookieParser::context& ctx) {
|
||||
bool loginValid = false;
|
||||
std::string loginKey = ctx.get_cookie("loginKey");
|
||||
std::string freelancerEmail = ctx.get_cookie("freelancerEmail");
|
||||
if (!freelancerEmail.empty() && !loginKey.empty())
|
||||
if (Utilities::checkFreelancerLoginState(configuration, loginKey, freelancerEmail))
|
||||
loginValid = true;
|
||||
|
||||
return loginValid;
|
||||
}
|
||||
}
|
||||
#endif
|
Reference in New Issue
Block a user