Move from session based state to client side tokens.

YACReaderHttpSession is still used, but it is not a http session anymore.
This commit is contained in:
Luis Ángel San Martín
2018-04-25 22:20:03 +02:00
parent 701817d76b
commit 630a5c94a0
9 changed files with 75 additions and 46 deletions

View File

@ -17,10 +17,16 @@
ComicControllerV2::ComicControllerV2() {}
void ComicControllerV2::service(HttpRequest& request, HttpResponse& response)
{
HttpSession session=Static::sessionStore->getSession(request,response,false);
YACReaderHttpSession *ySession = Static::yacreaderSessionStore->getYACReaderSessionHttpSession(session.getId());
{
QByteArray token = request.getHeader("x-request-id");
YACReaderHttpSession *ySession = Static::yacreaderSessionStore->getYACReaderSessionHttpSession(token);
if (ySession == nullptr) {
response.setStatus(404,"not found");
response.write("404 not found",true);
return;
}
QString path = QUrl::fromPercentEncoding(request.getPath()).toUtf8();
QStringList pathElements = path.split('/');
qulonglong libraryId = pathElements.at(3).toLongLong();
@ -45,9 +51,6 @@ void ComicControllerV2::service(HttpRequest& request, HttpResponse& response)
ComicDB comic = DBHelper::getComicInfo(libraryId, comicId);
if(!remoteComic)
ySession->setDownloadedComic(comic.info.hash);
Comic * comicFile = FactoryComic::newComic(libraries.getPath(libraryId)+comic.path);
if(comicFile != NULL)