| 397 | } |
| 398 | |
| 399 | bool BZFSHTTPAuth::generatePage(const HTTPRequest& request, HTTPReply& reply) { |
| 400 | if (!authPage.size()) { |
| 401 | setupAuth(); |
| 402 | } |
| 403 | |
| 404 | flushTasks(); |
| 405 | int sessionID = request.sessionID; |
| 406 | reply.docType = HTTPReply::eHTML; |
| 407 | reply.returnCode = HTTPReply::e200OK; |
| 408 | |
| 409 | std::map<int, AuthInfo>::iterator authItr = authedSessions.find(sessionID); |
| 410 | if (authItr != authedSessions.end()) { // it is one of our authorized users, be nice and forward the request to our child |
| 411 | // put this back to the default |
| 412 | reply.docType = HTTPReply::eText; |
| 413 | |
| 414 | authItr->second.time = bz_getCurrentTime(); |
| 415 | bool complete = handleAuthedRequest(authItr->second.level, request, reply); |
| 416 | |
| 417 | if (!complete) { |
| 418 | defferedAuthedRequests.push_back(request.requestID); |
| 419 | } |
| 420 | |
| 421 | return complete; |
| 422 | } |
| 423 | else { // they are not fully authorized yet |
| 424 | std::map<int, PendingTokenTask*>::iterator pendingItr = pendingTokenTasks.find(request.requestID); |
| 425 | if (pendingItr != pendingTokenTasks.end()) { // they have a token, check it |
| 426 | AuthInfo info; |
| 427 | info.time = bz_getCurrentTime(); |
| 428 | |
| 429 | if (!pendingItr->second->groups.size()) { |
| 430 | info.level = -1; |
| 431 | } |
| 432 | else { |
| 433 | if (pendingItr->second->groups.size() == 1) { |
| 434 | info.username = pendingItr->second->groups[0]; |
| 435 | info.level = 0; // just authed, no levels |
| 436 | } |
| 437 | else { |
| 438 | info.username = pendingItr->second->groups[0]; |
| 439 | info.level = getLevelFromGroups(pendingItr->second->groups); |
| 440 | info.groups = pendingItr->second->groups; |
| 441 | info.groups.erase(info.groups.begin()); // pull off the first 'group' because it's a name |
| 442 | } |
| 443 | if (info.level >= 0) { |
| 444 | authedSessions[request.sessionID] = info; |
| 445 | } |
| 446 | } |
| 447 | |
| 448 | delete(pendingItr->second); |
| 449 | pendingTokenTasks.erase(pendingItr); |
| 450 | |
| 451 | // put this back to the default |
| 452 | reply.docType = HTTPReply::eText; |
| 453 | |
| 454 | bool complete = handleAuthedRequest(info.level, request, reply); |
| 455 | |
| 456 | if (!complete) { |
nothing calls this directly
no test coverage detected