* Add phone call authentication method * Remove dynamic mem allocation from error handler * Add more error handling code * Move error handling to different file * Remove Socket IO dependency * cleanup in websocket code * Add rapidjson as cmake dependency * Added Dockerfiles as primary build system for packages * Changed policy in CMakeList to work with lower version of CMake * Fix opensuse builds * Link filesystem library in gcc 8.5 or older
44 lines
1.4 KiB
C++
44 lines
1.4 KiB
C++
#pragma once
|
|
|
|
#include <rublon/authentication_step_interface.hpp>
|
|
#include <rublon/configuration.hpp>
|
|
#include <rublon/json.hpp>
|
|
#include <rublon/method/method_select.hpp>
|
|
#include <sys/utsname.h>
|
|
|
|
namespace rublon {
|
|
class Finish : public AuthenticationStep {
|
|
const char * apiPath = "/api/transaction/credentials";
|
|
const std::string _accessToken;
|
|
|
|
void addAccessToken(Document & coreRequest) const {
|
|
auto & alloc = coreRequest.GetAllocator();
|
|
coreRequest.AddMember("accessToken", Value{_accessToken.c_str(), alloc}, alloc);
|
|
}
|
|
|
|
tl::expected< bool, Error > returnOk(const Document & /*coreResponse*/) const {
|
|
return true;
|
|
}
|
|
|
|
public:
|
|
const char * name = "Finalization";
|
|
|
|
Finish(Session & session, std::string accessToken) : AuthenticationStep(session), _accessToken{std::move(accessToken)} {}
|
|
|
|
template < typename Hander_t >
|
|
tl::expected< bool, Error > handle(const CoreHandlerInterface< Hander_t > & coreHandler) const {
|
|
const auto returnOk = [&](const auto & coreResponse) { return this->returnOk(coreResponse); };
|
|
|
|
RapidJSONPMRStackAlloc< 2048 > alloc{};
|
|
Document body{rapidjson::kObjectType, &alloc};
|
|
|
|
this->addSystemToken(body);
|
|
this->addAccessToken(body);
|
|
|
|
return coreHandler
|
|
.request(alloc, apiPath, body) //
|
|
.and_then(returnOk);
|
|
}
|
|
};
|
|
} // namespace rublon
|