chicken or egg problem.

member must exist in the database before we can generate a nonce & SSO URL
This commit is contained in:
Grant Limberg 2021-06-04 12:49:26 -07:00
parent fed1846c6f
commit 74a678c1e1
No known key found for this signature in database
GPG key ID: 2BA62CCABBB4095A
2 changed files with 66 additions and 64 deletions

View file

@ -1338,17 +1338,16 @@ void EmbeddedNetworkController::_request(
int64_t authenticationExpiryTime = (int64_t)OSUtils::jsonInt(member["authenticationExpiryTime"], 0);
fprintf(stderr, "authExpiryTime: %lld\n", authenticationExpiryTime);
if ((authenticationExpiryTime == 0) || (authenticationExpiryTime < now)) {
Dictionary<1024> authInfo;
std::string authenticationURL = _db.getSSOAuthURL(member);
if (!authenticationURL.empty()) {
Dictionary<1024> authInfo;
authInfo.add("aU", authenticationURL.c_str());
fprintf(stderr, "sending auth URL: %s\n", authenticationURL.c_str());
DB::cleanMember(member);
_db.save(member,true);
_sender->ncSendError(nwid,requestPacketId,identity.address(),NetworkController::NC_ERROR_AUTHENTICATION_REQUIRED, authInfo.data(), authInfo.sizeBytes());
return;
}
fprintf(stderr, "sending auth URL: %s\n", authenticationURL.c_str());
DB::cleanMember(member);
_db.save(member,true);
_sender->ncSendError(nwid,requestPacketId,identity.address(),NetworkController::NC_ERROR_AUTHENTICATION_REQUIRED, authInfo.data(), authInfo.sizeBytes());
return;
}
}