add api call to check is user has an elopage account to login-server and to apollo-server

This commit is contained in:
einhornimmond 2021-10-07 16:08:14 +02:00
parent 49ad4d87ca
commit cc8a4fcd5b
5 changed files with 49 additions and 2 deletions

View File

@ -242,4 +242,16 @@ export class UserResolver {
}
return new CheckEmailResponse(result.data)
}
}
@Query(() => Boolean)
async hasElopage(@Ctx() context: any): Promise<Boolean> {
const result = await apiGet(
CONFIG.LOGIN_API_URL + 'hasElopage?session_id=' + context.sessionId,
)
if (!result.success) {
throw new Error(result.data)
}
return result.data.hasElopage
}
}

View File

@ -0,0 +1,16 @@
#include "JsonHasElopage.h"
#include "../model/table/ElopageBuy.h"
Poco::JSON::Object* JsonHasElopage::handle(Poco::Dynamic::Var params)
{
auto result = checkAndLoadSession(params);
if (result) {
return result;
}
auto elopage_buy = Poco::AutoPtr<model::table::ElopageBuy>();
result = stateSuccess();
result->set("hasElopage", elopage_buy->isExistInDB("email", mSession->getNewUser()->getModel()->getEmail()));
return result;
}

View File

@ -0,0 +1,15 @@
#ifndef __JSON_INTERFACE_JSON_HAS_ELOPAGE_
#define __JSON_INTERFACE_JSON_HAS_ELOPAGE_
#include "JsonRequestHandler.h"
class JsonHasElopage : public JsonRequestHandler
{
public:
Poco::JSON::Object* handle(Poco::Dynamic::Var params);
protected:
};
#endif // __JSON_INTERFACE_JSON_HAS_ELOPAGE_

View File

@ -16,6 +16,7 @@
#include "JsonUnknown.h"
#include "JsonGetRunningUserTasks.h"
#include "JsonGetUsers.h"
#include "JsonHasElopage.h"
#include "JsonLoginViaEmailVerificationCode.h"
#include "JsonLogout.h"
#include "JsonNetworkInfos.h"
@ -140,6 +141,9 @@ Poco::Net::HTTPRequestHandler* JsonRequestHandlerFactory::createRequestHandler(c
else if (url_first_part == "/logout") {
return new JsonLogout(client_host);
}
else if (url_first_part == "/hasElopage") {
return new JsonHasElopage;
}
return new JsonUnknown;
}

View File

@ -171,7 +171,7 @@ namespace model {
<< " WHERE " << fieldName << " = ?"
, Poco::Data::Keywords::into(id), Poco::Data::Keywords::useRef(fieldValue);
try {
if (select.execute() == 1) {
if (select.execute() >= 1) {
return true;
}
}