Fixing the last command bugs

This commit is contained in:
stephb9959
2021-03-07 12:28:35 -08:00
parent ee3f54a639
commit 709bb15dbd
15 changed files with 245 additions and 128 deletions

View File

@@ -49,7 +49,7 @@ namespace uCentral::Auth {
void Service::Stop() {
}
bool Service::IsAuthorized(Poco::Net::HTTPServerRequest & Request)
bool Service::IsAuthorized(Poco::Net::HTTPServerRequest & Request, std::string & SessionToken)
{
if(!Secure_)
return true;
@@ -63,12 +63,23 @@ namespace uCentral::Auth {
auto Token = Tokens_.find(RequestToken);
return Token != Tokens_.end();
if( Token == Tokens_.end() )
return false;
SessionToken = RequestToken;
return true;
}
return false;
}
void Service::Logout(const std::string &token) {
std::lock_guard<std::mutex> guard(mutex_);
Tokens_.erase(token);
}
std::string Service::GenerateToken() {
static char buf[]={"1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRESTUVWXYZ"};