mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
merge
This commit is contained in:
commit
8e244ae417
4
.gitmodules
vendored
4
.gitmodules
vendored
@ -6,10 +6,10 @@
|
||||
url = https://github.com/MariaDB/mariadb-connector-c.git
|
||||
[submodule "src/proto"]
|
||||
path = src/proto
|
||||
url = ssh://git@***REMOVED***/~/gradido_protocol
|
||||
url = https://github.com/gradido/gradido_protocol.git
|
||||
[submodule "dependencies/iroha-ed25519"]
|
||||
path = dependencies/iroha-ed25519
|
||||
url = ssh://git@***REMOVED***/~/forks/iroha-ed25519.git
|
||||
url = https://github.com/gradido/iroha-ed25519.git
|
||||
[submodule "dependencies/spirit-po"]
|
||||
path = dependencies/spirit-po
|
||||
url = https://github.com/cbeck88/spirit-po.git
|
||||
|
||||
@ -108,8 +108,11 @@ set(GRPC_PROTOBUF_PATH "${GRPC_PATH}/third_party/protobuf")
|
||||
|
||||
if(WIN32)
|
||||
|
||||
find_library(MYSQL_LIBRARIES mariadbclient.lib PATHS "${MARIADB_CONNECTOR_PATH}/Release" REQUIRED)
|
||||
find_library(MYSQL_LIBRARIES mariadbclient PATHS "${MARIADB_CONNECTOR_PATH}/Release" REQUIRED)
|
||||
find_library(COMPILED_MARIADB_CLIENT_DEBUG mariadbclient PATHS "${MARIADB_CONNECTOR_PATH}/Debug" REQUIRED)
|
||||
|
||||
find_library(CONAN_OPENSSL_SSL ssleay32 PATHS ${CONAN_LIB_DIRS_OPENSSL} REQUIRED NO_DEFAULT_PATH )
|
||||
find_library(CONAN_OPENSSL_CRYPTO libeay32 PATHS ${CONAN_LIB_DIRS_OPENSSL} REQUIRED NO_DEFAULT_PATH )
|
||||
|
||||
set(GRPC_PATH "${GRPC_PATH}/Debug")
|
||||
set(GRPC_ABSL_PATH "${GRPC_ABSL_PATH}/Debug")
|
||||
@ -118,15 +121,6 @@ if(WIN32)
|
||||
set(GRPC_RE2_PATH "${GRPC_RE2_PATH}/Debug")
|
||||
set(GRPC_PROTOBUF_DEBUG_PATH "${GRPC_PROTOBUF_PATH}/Debug")
|
||||
|
||||
find_library(PROTOBUF_LIB_DEBUG libprotobufd PATHS ${GRPC_PROTOBUF_DEBUG_PATH} REQUIRED)
|
||||
find_library(PROTOBUF_LIB_LITE_DEBUG libprotobuf-lited PATHS ${GRPC_PROTOBUF_DEBUG_PATH} REQUIRED)
|
||||
find_library(PROTOBUF_LIBC_DEBUG libprotocd PATHS ${GRPC_PROTOBUF_DEBUG_PATH} REQUIRED)
|
||||
|
||||
set(PROTOBUF_DEBUG_LIBS
|
||||
${PROTOBUF_LIB_DEBUG}
|
||||
${PROTOBUF_LIB_LITE_DEBUG}
|
||||
${PROTOBUF_LIBC_DEBUG}
|
||||
)
|
||||
|
||||
list(REMOVE_ITEM CONAN_LIBS "libeay32.lib")
|
||||
list(REMOVE_ITEM CONAN_LIBS "ssleay32.lib")
|
||||
@ -135,20 +129,28 @@ if(WIN32)
|
||||
else (WIN32)
|
||||
#find_package(MariaDBClient PATHS "dependencies/cmake-modules")
|
||||
#find_library(MYSQL_LIBRARIES libmariadb.so PATHS ${MARIADB_CONNECTOR_PATH} REQUIRED)
|
||||
find_library(CONAN_OPENSSL_SSL ssl PATHS ${CONAN_LIB_DIRS_OPENSSL} REQUIRED NO_DEFAULT_PATH )
|
||||
find_library(CONAN_OPENSSL_CRYPTO crypto PATHS ${CONAN_LIB_DIRS_OPENSSL} REQUIRED NO_DEFAULT_PATH )
|
||||
set(GRPC_PROTOBUF_DEBUG_PATH "${GRPC_PROTOBUF_PATH}")
|
||||
|
||||
list(REMOVE_ITEM CONAN_LIBS "ssl")
|
||||
list(REMOVE_ITEM CONAN_LIBS "crypto")
|
||||
list(REMOVE_ITEM CONAN_LIBS "dl")
|
||||
|
||||
find_library(MYSQL_LIBRARIES libmariadb.so PATHS ${MARIADB_CONNECTOR_PATH} REQUIRED)
|
||||
find_library(CONAN_OPENSSL_SSL ssl PATHS ${CONAN_LIB_DIRS_OPENSSL} REQUIRED NO_DEFAULT_PATH )
|
||||
find_library(CONAN_OPENSSL_CRYPTO crypto PATHS ${CONAN_LIB_DIRS_OPENSSL} REQUIRED NO_DEFAULT_PATH )
|
||||
set(GRPC_PROTOBUF_DEBUG_PATH "${GRPC_PROTOBUF_PATH}")
|
||||
|
||||
list(REMOVE_ITEM CONAN_LIBS "ssl")
|
||||
list(REMOVE_ITEM CONAN_LIBS "crypto")
|
||||
list(REMOVE_ITEM CONAN_LIBS "dl")
|
||||
|
||||
endif(WIN32)
|
||||
|
||||
# load same ssl version like used from poco
|
||||
#find_package(OpenSSL PATHS "../" NO_DEFAULT_PATH)
|
||||
|
||||
find_library(CONAN_OPENSSL_SSL ssl PATHS ${CONAN_LIB_DIRS_OPENSSL} REQUIRED NO_DEFAULT_PATH )
|
||||
find_library(CONAN_OPENSSL_CRYPTO crypto PATHS ${CONAN_LIB_DIRS_OPENSSL} REQUIRED NO_DEFAULT_PATH )
|
||||
|
||||
set(CONAN_OPENSSL_CUSTOM_LIBS
|
||||
${CONAN_OPENSSL_SSL}
|
||||
@ -224,5 +226,3 @@ else(WIN32)
|
||||
endif(WIN32)
|
||||
|
||||
add_test(NAME main COMMAND Gradido_LoginServer_Test)
|
||||
|
||||
|
||||
|
||||
77
Dockerfile
Normal file
77
Dockerfile
Normal file
@ -0,0 +1,77 @@
|
||||
#########################################################################################################
|
||||
# Build protoc
|
||||
#########################################################################################################
|
||||
FROM gcc:7.5 as protoc_build
|
||||
RUN git clone --recurse-submodules https://github.com/protocolbuffers/protobuf.git
|
||||
WORKDIR /protobuf
|
||||
|
||||
RUN git checkout v3.9.1
|
||||
RUN ./autogen.sh
|
||||
RUN ./configure --enable-static=yes
|
||||
RUN make -j$(grep processor /proc/cpuinfo | wc -l)
|
||||
RUN make check
|
||||
|
||||
CMD ["./protobuf"]
|
||||
|
||||
#########################################################################################################
|
||||
# Build release
|
||||
#########################################################################################################
|
||||
From conanio/gcc7 as release
|
||||
|
||||
ENV DOCKER_WORKDIR="/code"
|
||||
|
||||
USER root
|
||||
|
||||
COPY --from=protoc_build /protobuf/src/.libs/protoc /usr/bin/
|
||||
COPY --from=protoc_build /protobuf/src/.libs/libprotobuf.so.20.0.1 /usr/lib/libprotobuf.so.20
|
||||
COPY --from=protoc_build /protobuf/src/.libs/libprotoc.so.20.0.1 /usr/lib/libprotoc.so.20
|
||||
COPY --from=protoc_build /protobuf/src/google/protobuf/*.proto /usr/include/google/protobuf/
|
||||
COPY --from=protoc_build /protobuf/src/google/protobuf/*.h /usr/include/google/protobuf/
|
||||
|
||||
|
||||
RUN mkdir -p ${DOCKER_WORKDIR}
|
||||
WORKDIR ${DOCKER_WORKDIR}
|
||||
|
||||
COPY . .
|
||||
#RUN git submodule update --init --recursive
|
||||
RUN ls -la
|
||||
RUN cd dependencies/iroha-ed25519 && \
|
||||
ls -la && \
|
||||
mkdir build && \
|
||||
cd build && \
|
||||
cmake .. -DEDIMPL=ref10 -DHASH=sha2_sphlib -DRANDOM=bcryptgen -DBUILD=STATIC && \
|
||||
make -j$(grep processor /proc/cpuinfo | wc -l)
|
||||
|
||||
RUN cd dependencies/mariadb-connector-c && \
|
||||
mkdir build && \
|
||||
cd build && \
|
||||
cmake -DWITH_SSL=OFF ..
|
||||
|
||||
RUN chmod +x compile_proto.sh
|
||||
RUN chmod +x compile_pot.sh
|
||||
RUN ls -la
|
||||
RUN ./compile_pot.sh
|
||||
RUN ./compile_proto.sh
|
||||
RUN mkdir build && \
|
||||
cd build && \
|
||||
conan install .. --build=missing && \
|
||||
cmake .. && \
|
||||
make -j$(grep processor /proc/cpuinfo | wc -l) Gradido_LoginServer
|
||||
|
||||
|
||||
CMD ["./code"]
|
||||
|
||||
#########################################################################################################
|
||||
# run release
|
||||
#########################################################################################################
|
||||
#From alpine:latest as login_server
|
||||
FROM alpine:latest as login_server
|
||||
|
||||
WORKDIR "/usr/bin"
|
||||
|
||||
COPY --from=release /code/build/bin/Gradido_LoginServer /usr/bin/
|
||||
COPY --from=release /code/build/lib/libmariadb.so.3 /usr/lib/
|
||||
|
||||
RUN chmod +x /usr/bin/Gradido_LoginServer
|
||||
ENTRYPOINT ["/usr/bin/Gradido_LoginServer"]
|
||||
CMD Gradido_LoginServer
|
||||
132
Dockerfile.debug
Normal file
132
Dockerfile.debug
Normal file
@ -0,0 +1,132 @@
|
||||
#########################################################################################################
|
||||
# Build protoc
|
||||
#########################################################################################################
|
||||
FROM gcc:7.5 as protoc_build
|
||||
RUN git clone --recurse-submodules https://github.com/protocolbuffers/protobuf.git
|
||||
WORKDIR /protobuf
|
||||
|
||||
RUN git checkout v3.9.1
|
||||
RUN ./autogen.sh
|
||||
RUN ./configure --enable-static=yes
|
||||
RUN make -j$(grep processor /proc/cpuinfo | wc -l)
|
||||
RUN make check
|
||||
|
||||
CMD ["./protobuf"]
|
||||
|
||||
#########################################################################################################
|
||||
# debug build preparation
|
||||
#########################################################################################################
|
||||
|
||||
From conanio/gcc7 as debug_preparation
|
||||
|
||||
ENV DOCKER_WORKDIR="/code"
|
||||
|
||||
USER root
|
||||
|
||||
COPY --from=protoc_build /protobuf/src/.libs/protoc /usr/bin/
|
||||
COPY --from=protoc_build /protobuf/src/.libs/libprotobuf.so.20.0.1 /usr/lib/libprotobuf.so.20
|
||||
COPY --from=protoc_build /protobuf/src/.libs/libprotoc.so.20.0.1 /usr/lib/libprotoc.so.20
|
||||
COPY --from=protoc_build /protobuf/src/google/protobuf/*.proto /usr/include/google/protobuf/
|
||||
COPY --from=protoc_build /protobuf/src/google/protobuf/*.h /usr/include/google/protobuf/
|
||||
|
||||
#VOLUME /root/.conan
|
||||
|
||||
RUN mkdir -p ${DOCKER_WORKDIR}
|
||||
WORKDIR ${DOCKER_WORKDIR}
|
||||
|
||||
COPY ./dependencies ./dependencies
|
||||
COPY ./conanfile.txt ./conanfile.txt
|
||||
|
||||
RUN ls -la
|
||||
RUN cd dependencies/iroha-ed25519 && \
|
||||
ls -la && \
|
||||
mkdir build && \
|
||||
cd build && \
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Debug -DEDIMPL=ref10 -DHASH=sha2_sphlib -DRANDOM=bcryptgen -DBUILD=STATIC && \
|
||||
make -j$(grep processor /proc/cpuinfo | wc -l)
|
||||
|
||||
RUN cd dependencies/mariadb-connector-c && \
|
||||
mkdir build && \
|
||||
cd build && \
|
||||
cmake -DCMAKE_BUILD_TYPE=Debug -DWITH_SSL=OFF ..
|
||||
|
||||
|
||||
#RUN chmod +x compile_proto.sh
|
||||
#RUN chmod +x compile_pot.sh
|
||||
#RUN ls -la
|
||||
#RUN ./compile_pot.sh
|
||||
#RUN ./compile_proto.sh
|
||||
RUN mkdir build && \
|
||||
cd build && \
|
||||
conan install .. --build=missing -s build_type=Debug
|
||||
|
||||
|
||||
|
||||
#########################################################################################################
|
||||
# Build debug
|
||||
#########################################################################################################
|
||||
From debug_preparation as debug
|
||||
|
||||
ENV DOCKER_WORKDIR="/code"
|
||||
|
||||
USER root
|
||||
#VOLUME /root/.conan
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get install -y --no-install-recommends gdb && \
|
||||
apt-get autoclean && \
|
||||
apt-get autoremove && \
|
||||
apt-get clean && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
#COPY --from=protoc_build /protobuf/src/.libs/libprotobuf.so.20.0.1 /usr/lib/libprotobuf.so.20
|
||||
#COPY --from=protoc_build /protobuf/src/google/protobuf/*.h /usr/include/google/protobuf/
|
||||
|
||||
|
||||
#COPY --from=debug_preparation /code /code
|
||||
#COPY --from=debug_preparation /home/conan /home/conan
|
||||
#RUN ls -la /home/conan/.conan
|
||||
COPY . .
|
||||
WORKDIR ${DOCKER_WORKDIR}
|
||||
|
||||
#RUN ls -la
|
||||
#RUN cat build/conanbuildinfo.cmake
|
||||
RUN chmod +x compile_proto.sh
|
||||
RUN chmod +x compile_pot.sh
|
||||
#RUN ls -la
|
||||
RUN ./compile_pot.sh
|
||||
RUN ./compile_proto.sh
|
||||
RUN cd build && \
|
||||
cmake -DCMAKE_BUILD_TYPE=Debug .. && \
|
||||
make -j$(grep processor /proc/cpuinfo | wc -l)
|
||||
|
||||
|
||||
#########################################################################################################
|
||||
# run debug
|
||||
#########################################################################################################
|
||||
FROM ubuntu:latest as login_server_debug
|
||||
|
||||
WORKDIR "/usr/bin"
|
||||
|
||||
#RUN apt-get update && \
|
||||
# apt-get install -y --no-install-recommends gdb && \
|
||||
# apt-get autoclean && \
|
||||
# apt-get autoremove && \
|
||||
# apt-get clean && \
|
||||
# rm -rf /var/lib/apt/lists/*
|
||||
|
||||
VOLUME /var/log/grd_login
|
||||
|
||||
COPY --from=debug /code/build/bin/Gradido_LoginServer /usr/bin/
|
||||
COPY --from=debug /code/build/lib/libmariadb.so.3 /usr/lib/
|
||||
#COPY start_after_mysql.sh .
|
||||
RUN chmod +x /usr/bin/Gradido_LoginServer
|
||||
EXPOSE 1200
|
||||
EXPOSE 1201
|
||||
#ENTRYPOINT ["/usr/bin/Gradido_LoginServer"]
|
||||
# Wait on mariadb to started
|
||||
#CMD ["sleep 5", "/usr/bin/Gradido_LoginServer"]
|
||||
#RUN chmod +x ./start_after_mysql.sh
|
||||
#ENTRYPOINT ["/usr/bin/Gradido_LoginServer"]
|
||||
#CMD gdb -ex=r Gradido_LoginServer
|
||||
CMD Gradido_LoginServer
|
||||
16
README
16
README
@ -9,15 +9,6 @@ cmake -DWITH_SSL=OFF ..
|
||||
cd ../../../
|
||||
|
||||
|
||||
cd dependencies/grpc
|
||||
mkdir build
|
||||
cd build
|
||||
cmake ..
|
||||
make
|
||||
# under windows build at least release for protoc.exe and grpc c++ plugin
|
||||
cd ../../../
|
||||
./unix_parse_proto.sh
|
||||
|
||||
# get more dependencies with conan (need conan from https://conan.io/)
|
||||
mkdir build && cd build
|
||||
# // not used anymore
|
||||
@ -29,3 +20,10 @@ conan install ..
|
||||
# build Makefile with cmake
|
||||
cmake ..
|
||||
|
||||
make grpc
|
||||
# under windows build at least release for protoc.exe and grpc c++ plugin
|
||||
cd ../
|
||||
./unix_parse_proto.sh
|
||||
cd build
|
||||
make
|
||||
|
||||
|
||||
@ -1,2 +1,2 @@
|
||||
#!/bin/bash
|
||||
xgettext -D src/cpp -p src/LOCALE -o messages.pot --from-code=UTF-8 --files-from=files_to_translate.txt
|
||||
xgettext -D src/cpp -p src/LOCALE -o messages.pot --from-code=UTF-8 --files-from=files_to_translate.txt
|
||||
|
||||
2
dependencies/mariadb-connector-c
vendored
2
dependencies/mariadb-connector-c
vendored
@ -1 +1 @@
|
||||
Subproject commit 1f7480118acfe12be9e356827aa30ae9b9eca9a7
|
||||
Subproject commit 159540fe8c8f30b281748fe8a1b79e8b17993a67
|
||||
@ -14,5 +14,3 @@ fi
|
||||
|
||||
|
||||
./protoc --plugin=protoc-gen-grpc=./grpc_cpp_plugin.exe --cpp_out=./src/cpp/proto/hedera --grpc_out=./src/cpp/proto/hedera --proto_path=./src/proto/hedera/hedera-protobuf/src/main/proto ./src/proto/hedera/hedera-protobuf/src/main/proto/*.proto
|
||||
|
||||
|
||||
|
||||
@ -64,8 +64,10 @@ int Mnemonic::init(void(*fill_words_func)(unsigned char*), unsigned int original
|
||||
uncompressed_file_name += std::to_string(original_size);
|
||||
uncompressed_file_name += ".txt";
|
||||
FILE* f = fopen(uncompressed_file_name.data(), "w");
|
||||
fwrite(uncompressed_buffer, sizeof(char), original_size, f);
|
||||
fclose(f);
|
||||
if (f) {
|
||||
fwrite(uncompressed_buffer, sizeof(char), original_size, f);
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
unsigned short cursor = 0;
|
||||
u32 word_begin = 0, word_end = 0;
|
||||
@ -335,9 +337,11 @@ void Mnemonic::printToFile(const char* filename)
|
||||
{
|
||||
std::shared_lock<std::shared_mutex> _lock(mWorkingMutex);
|
||||
FILE* f = fopen(filename, "wt");
|
||||
auto words = getCompleteWordListSorted();
|
||||
fwrite(words.data(), 1, words.size(), f);
|
||||
fclose(f);
|
||||
if (f) {
|
||||
auto words = getCompleteWordListSorted();
|
||||
fwrite(words.data(), 1, words.size(), f);
|
||||
fclose(f);
|
||||
}
|
||||
}
|
||||
|
||||
Poco::JSON::Array Mnemonic::getSortedWordList()
|
||||
|
||||
@ -56,14 +56,25 @@ void Gradido_LoginServer::defineOptions(Poco::Util::OptionSet& options)
|
||||
{
|
||||
ServerApplication::defineOptions(options);
|
||||
|
||||
options.addOption(
|
||||
/*options.addOption(
|
||||
Poco::Util::Option("help", "h", "display help information on command line arguments")
|
||||
.required(false)
|
||||
.repeatable(false));
|
||||
.repeatable(false));*/
|
||||
options.addOption(
|
||||
Poco::Util::Option("config", "c", "use non default config file (default is /etc/grd_login.properties)", false)
|
||||
.repeatable(false)
|
||||
.argument("Gradido_LoginServer.properties", true)
|
||||
.callback(Poco::Util::OptionCallback<Gradido_LoginServer>(this, &Gradido_LoginServer::handleOption)));
|
||||
|
||||
}
|
||||
|
||||
void Gradido_LoginServer::handleOption(const std::string& name, const std::string& value)
|
||||
{
|
||||
//printf("handle option: %s with value: %s\n", name.data(), value.data());
|
||||
if (name == "config") {
|
||||
mConfigPath = value;
|
||||
return;
|
||||
}
|
||||
ServerApplication::handleOption(name, value);
|
||||
if (name == "help") _helpRequested = true;
|
||||
}
|
||||
@ -189,8 +200,22 @@ int Gradido_LoginServer::main(const std::vector<std::string>& args)
|
||||
}
|
||||
|
||||
auto conn = ConnectionManager::getInstance();
|
||||
|
||||
conn->setConnectionsFromConfig(config(), CONNECTION_MYSQL_LOGIN_SERVER);
|
||||
//conn->setConnection()
|
||||
//printf("try connect login server mysql db\n");
|
||||
try {
|
||||
conn->setConnectionsFromConfig(config(), CONNECTION_MYSQL_LOGIN_SERVER);
|
||||
}
|
||||
catch (Poco::Exception& ex) {
|
||||
// maybe we in docker environment and db needs some time to start up
|
||||
// let's wait 10 seconds
|
||||
int count = 10;
|
||||
while (count > 0) {
|
||||
printf("\rwait on mysql/mariadb %d seconds...", count);
|
||||
count--;
|
||||
Poco::Thread::sleep(1000);
|
||||
}
|
||||
conn->setConnectionsFromConfig(config(), CONNECTION_MYSQL_LOGIN_SERVER);
|
||||
}
|
||||
//printf("try connect php server mysql \n");
|
||||
//conn->setConnectionsFromConfig(config(), CONNECTION_MYSQL_PHP_SERVER);
|
||||
|
||||
@ -243,5 +268,4 @@ int Gradido_LoginServer::main(const std::vector<std::string>& args)
|
||||
|
||||
}
|
||||
return Application::EXIT_OK;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,41 +1,42 @@
|
||||
#ifndef Gradido_LoginServer_INCLUDED
|
||||
#define Gradido_LoginServer_INCLUDED
|
||||
|
||||
#include "Poco/Util/ServerApplication.h"
|
||||
|
||||
class Gradido_LoginServer : public Poco::Util::ServerApplication
|
||||
{
|
||||
|
||||
/// The main application class.
|
||||
///
|
||||
/// This class handles command-line arguments and
|
||||
/// configuration files.
|
||||
/// Start the Gradido_LoginServer executable with the help
|
||||
/// option (/help on Windows, --help on Unix) for
|
||||
/// the available command line options.
|
||||
///
|
||||
|
||||
|
||||
public:
|
||||
Gradido_LoginServer();
|
||||
~Gradido_LoginServer();
|
||||
|
||||
protected:
|
||||
void initialize(Application& self);
|
||||
|
||||
void uninitialize();
|
||||
|
||||
void defineOptions(Poco::Util::OptionSet& options);
|
||||
|
||||
void handleOption(const std::string& name, const std::string& value);
|
||||
void displayHelp();
|
||||
|
||||
int main(const std::vector<std::string>& args);
|
||||
|
||||
void createConsoleFileAsyncLogger(std::string name, std::string filePath);
|
||||
|
||||
private:
|
||||
bool _helpRequested;
|
||||
};
|
||||
|
||||
#endif //Gradido_LoginServer_INCLUDED
|
||||
#ifndef Gradido_LoginServer_INCLUDED
|
||||
#define Gradido_LoginServer_INCLUDED
|
||||
|
||||
#include "Poco/Util/ServerApplication.h"
|
||||
|
||||
class Gradido_LoginServer : public Poco::Util::ServerApplication
|
||||
{
|
||||
|
||||
/// The main application class.
|
||||
///
|
||||
/// This class handles command-line arguments and
|
||||
/// configuration files.
|
||||
/// Start the Gradido_LoginServer executable with the help
|
||||
/// option (/help on Windows, --help on Unix) for
|
||||
/// the available command line options.
|
||||
///
|
||||
|
||||
|
||||
public:
|
||||
Gradido_LoginServer();
|
||||
~Gradido_LoginServer();
|
||||
|
||||
protected:
|
||||
void initialize(Application& self);
|
||||
|
||||
void uninitialize();
|
||||
|
||||
void defineOptions(Poco::Util::OptionSet& options);
|
||||
|
||||
void handleOption(const std::string& name, const std::string& value);
|
||||
void displayHelp();
|
||||
|
||||
int main(const std::vector<std::string>& args);
|
||||
|
||||
void createConsoleFileAsyncLogger(std::string name, std::string filePath);
|
||||
|
||||
private:
|
||||
bool _helpRequested;
|
||||
std::string mConfigPath;
|
||||
};
|
||||
|
||||
#endif //Gradido_LoginServer_INCLUDED
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
#include "Poco/DeflatingStream.h"
|
||||
|
||||
|
||||
#line 7 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 7 "F:\\Gradido\\gradido_login_server_production\\src\\cpsp\\checkTransaction.cpsp"
|
||||
|
||||
#include "../SingletonManager/SessionManager.h"
|
||||
#include "../SingletonManager/SingletonTaskObserver.h"
|
||||
@ -38,7 +38,7 @@ void CheckTransactionPage::handleRequest(Poco::Net::HTTPServerRequest& request,
|
||||
if (_compressResponse) response.set("Content-Encoding", "gzip");
|
||||
|
||||
Poco::Net::HTMLForm form(request, request.stream());
|
||||
#line 24 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 24 "F:\\Gradido\\gradido_login_server_production\\src\\cpsp\\checkTransaction.cpsp"
|
||||
|
||||
const char* pageName = gettext("Überprüfe Transaktion");
|
||||
auto account_user = mSession->getNewUser();
|
||||
@ -56,11 +56,16 @@ void CheckTransactionPage::handleRequest(Poco::Net::HTTPServerRequest& request,
|
||||
hasErrors = true;
|
||||
}
|
||||
|
||||
bool transaction_finalize_run = false;
|
||||
bool transaction_finalize_result = false;
|
||||
|
||||
if(!form.empty()) {
|
||||
auto ok = form.get("ok", "");
|
||||
auto abort = form.get("abort", "");
|
||||
auto back = form.get("back", "");
|
||||
if(abort != "") {
|
||||
mSession->finalizeTransaction(false, true);
|
||||
transaction_finalize_result = mSession->finalizeTransaction(false, true);
|
||||
transaction_finalize_run = true;
|
||||
} else if(ok != "") {
|
||||
if(!account_user->hasPassword()) {
|
||||
auto pwd = form.get("sign-password", "");
|
||||
@ -83,15 +88,26 @@ void CheckTransactionPage::handleRequest(Poco::Net::HTTPServerRequest& request,
|
||||
}
|
||||
}
|
||||
if(!hasErrors) {
|
||||
mSession->finalizeTransaction(true, false);
|
||||
transaction_finalize_result = mSession->finalizeTransaction(true, false);
|
||||
transaction_finalize_run = true;
|
||||
}
|
||||
} else if(back == "back") {
|
||||
auto lastExternReferer = mSession->getLastReferer();
|
||||
//lastExternReferer = "";
|
||||
if(lastExternReferer != "" && lastExternReferer.find("transaction-send-coins") == std::string::npos) {
|
||||
//printf("last extern referer: %s\n", lastExternReferer.data());
|
||||
response.redirect(lastExternReferer);
|
||||
} else {
|
||||
response.redirect(ServerConfig::g_php_serverPath + "state-balances/overview");
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
size_t notReadyTransactions = 0;
|
||||
size_t sumTransactions = mSession->getProcessingTransactionCount();
|
||||
if(sumTransactions == 0) {
|
||||
if(sumTransactions == 0 && !transaction_finalize_run) {
|
||||
/*auto observer = SingletonTaskObserver::getInstance();
|
||||
auto emailHash = DRMakeStringHash(mSession->getUser()->getEmail());
|
||||
int breakCount = 0;
|
||||
@ -136,23 +152,23 @@ void CheckTransactionPage::handleRequest(Poco::Net::HTTPServerRequest& request,
|
||||
responseStream << " <meta charset=\"UTF-8\">\n";
|
||||
responseStream << " <meta name=\"viewport\" content=\"width=device-width, initial-scale=1, shrink-to-fit=no\">\n";
|
||||
responseStream << " <title>Gradido Login Server: ";
|
||||
#line 7 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\header_navi_chr.cpsp"
|
||||
#line 7 "F:\\Gradido\\gradido_login_server_production\\src\\cpsp\\header_navi_chr.cpsp"
|
||||
responseStream << ( pageName );
|
||||
responseStream << "</title>\n";
|
||||
responseStream << " <link href=\"";
|
||||
#line 8 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\header_navi_chr.cpsp"
|
||||
#line 8 "F:\\Gradido\\gradido_login_server_production\\src\\cpsp\\header_navi_chr.cpsp"
|
||||
responseStream << ( ServerConfig::g_php_serverPath );
|
||||
responseStream << "favicon.ico\" type=\"image/x-icon\" rel=\"icon\" />\n";
|
||||
responseStream << " <link href=\"";
|
||||
#line 9 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\header_navi_chr.cpsp"
|
||||
#line 9 "F:\\Gradido\\gradido_login_server_production\\src\\cpsp\\header_navi_chr.cpsp"
|
||||
responseStream << ( ServerConfig::g_php_serverPath );
|
||||
responseStream << "favicon.ico\" type=\"image/x-icon\" rel=\"shortcut icon\" />\n";
|
||||
responseStream << " <link rel=\"stylesheet\" href=\"";
|
||||
#line 10 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\header_navi_chr.cpsp"
|
||||
#line 10 "F:\\Gradido\\gradido_login_server_production\\src\\cpsp\\header_navi_chr.cpsp"
|
||||
responseStream << ( ServerConfig::g_php_serverPath );
|
||||
responseStream << "css/main.css\" />\n";
|
||||
responseStream << " <script src=\"";
|
||||
#line 11 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\header_navi_chr.cpsp"
|
||||
#line 11 "F:\\Gradido\\gradido_login_server_production\\src\\cpsp\\header_navi_chr.cpsp"
|
||||
responseStream << ( ServerConfig::g_php_serverPath );
|
||||
responseStream << "js/basic.js\"></script>\n";
|
||||
responseStream << "</head>\n";
|
||||
@ -163,34 +179,34 @@ void CheckTransactionPage::handleRequest(Poco::Net::HTTPServerRequest& request,
|
||||
responseStream << " </div>\n";
|
||||
responseStream << " <div class=\"sidebar1 nav-menu initial\">\n";
|
||||
responseStream << " <a href=\"";
|
||||
#line 19 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\header_navi_chr.cpsp"
|
||||
#line 19 "F:\\Gradido\\gradido_login_server_production\\src\\cpsp\\header_navi_chr.cpsp"
|
||||
responseStream << ( ServerConfig::g_php_serverPath );
|
||||
responseStream << "\">\n";
|
||||
responseStream << " <picture class=\"logo big visible\">\n";
|
||||
responseStream << " <source srcset=\"";
|
||||
#line 21 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\header_navi_chr.cpsp"
|
||||
#line 21 "F:\\Gradido\\gradido_login_server_production\\src\\cpsp\\header_navi_chr.cpsp"
|
||||
responseStream << ( ServerConfig::g_php_serverPath );
|
||||
responseStream << "img/logo_schrift_half.webp\" type=\"image/webp\">\n";
|
||||
responseStream << " <source srcset=\"";
|
||||
#line 22 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\header_navi_chr.cpsp"
|
||||
#line 22 "F:\\Gradido\\gradido_login_server_production\\src\\cpsp\\header_navi_chr.cpsp"
|
||||
responseStream << ( ServerConfig::g_php_serverPath );
|
||||
responseStream << "img/logo_schrift_half.png\" type=\"image/png\">\n";
|
||||
responseStream << " <img src=\"";
|
||||
#line 23 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\header_navi_chr.cpsp"
|
||||
#line 23 "F:\\Gradido\\gradido_login_server_production\\src\\cpsp\\header_navi_chr.cpsp"
|
||||
responseStream << ( ServerConfig::g_php_serverPath );
|
||||
responseStream << "img/logo_schrift_half.png\" class=\"logo big visible\" alt=\"Logo\">\n";
|
||||
responseStream << " </picture>\n";
|
||||
responseStream << " <picture class=\"logo small\">\n";
|
||||
responseStream << " <source srcset=\"";
|
||||
#line 26 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\header_navi_chr.cpsp"
|
||||
#line 26 "F:\\Gradido\\gradido_login_server_production\\src\\cpsp\\header_navi_chr.cpsp"
|
||||
responseStream << ( ServerConfig::g_php_serverPath );
|
||||
responseStream << "img/logo_half.webp\" type=\"image/webp\">\n";
|
||||
responseStream << " <source srcset=\"";
|
||||
#line 27 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\header_navi_chr.cpsp"
|
||||
#line 27 "F:\\Gradido\\gradido_login_server_production\\src\\cpsp\\header_navi_chr.cpsp"
|
||||
responseStream << ( ServerConfig::g_php_serverPath );
|
||||
responseStream << "img/logo_half.png\" type=\"image/png\">\n";
|
||||
responseStream << " <img src=\"";
|
||||
#line 28 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\header_navi_chr.cpsp"
|
||||
#line 28 "F:\\Gradido\\gradido_login_server_production\\src\\cpsp\\header_navi_chr.cpsp"
|
||||
responseStream << ( ServerConfig::g_php_serverPath );
|
||||
responseStream << "img/logo_half.png\" class=\"logo small\" alt=\"Logo\">\n";
|
||||
responseStream << " </picture>\n";
|
||||
@ -199,29 +215,29 @@ void CheckTransactionPage::handleRequest(Poco::Net::HTTPServerRequest& request,
|
||||
responseStream << " <i class=\"material-icons-outlined nav-main-button\">menu</i>\n";
|
||||
responseStream << " </div>\n";
|
||||
responseStream << " <div class=\"flash-messages\" onclick=\"this.classList.add('hidden')\">";
|
||||
#line 34 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\header_navi_chr.cpsp"
|
||||
#line 34 "F:\\Gradido\\gradido_login_server_production\\src\\cpsp\\header_navi_chr.cpsp"
|
||||
responseStream << ( getErrorsHtmlNewFormat() );
|
||||
responseStream << "</div>\n";
|
||||
responseStream << " <div class=\"nav-vertical\">\n";
|
||||
responseStream << " <ul>\n";
|
||||
responseStream << " <li><a href=\"";
|
||||
#line 37 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\header_navi_chr.cpsp"
|
||||
#line 37 "F:\\Gradido\\gradido_login_server_production\\src\\cpsp\\header_navi_chr.cpsp"
|
||||
responseStream << ( ServerConfig::g_php_serverPath );
|
||||
responseStream << "state-balances/overview\" class=\"\"><i class=\"material-icons-outlined nav-icon \" title=\"Kontoübersicht ( ";
|
||||
#line 37 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\header_navi_chr.cpsp"
|
||||
#line 37 "F:\\Gradido\\gradido_login_server_production\\src\\cpsp\\header_navi_chr.cpsp"
|
||||
responseStream << ( TransactionBase::amountToString(userBalance) );
|
||||
responseStream << " GDD )\">account_balance_wallet</i><span\n";
|
||||
responseStream << " class=\"link-title\">Kontoübersicht ( ";
|
||||
#line 38 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\header_navi_chr.cpsp"
|
||||
#line 38 "F:\\Gradido\\gradido_login_server_production\\src\\cpsp\\header_navi_chr.cpsp"
|
||||
responseStream << ( TransactionBase::amountToString(userBalance) );
|
||||
responseStream << " GDD )</span></a></li>\n";
|
||||
responseStream << " <li><a href=\"";
|
||||
#line 39 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\header_navi_chr.cpsp"
|
||||
#line 39 "F:\\Gradido\\gradido_login_server_production\\src\\cpsp\\header_navi_chr.cpsp"
|
||||
responseStream << ( ServerConfig::g_php_serverPath );
|
||||
responseStream << "dashboard/index\" class=\"\"><i class=\"material-icons-outlined nav-icon \" title=\"Startseite\">home</i><span\n";
|
||||
responseStream << " class=\"link-title\">Startseite</span></a></li>\n";
|
||||
responseStream << " <li class=' selected'><a href=\"";
|
||||
#line 41 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\header_navi_chr.cpsp"
|
||||
#line 41 "F:\\Gradido\\gradido_login_server_production\\src\\cpsp\\header_navi_chr.cpsp"
|
||||
responseStream << ( ServerConfig::g_php_serverPath );
|
||||
responseStream << "transaction-send-coins/create\" class=\"\"><i class=\"material-icons-outlined nav-icon \"\n";
|
||||
responseStream << " title=\"Überweisung\">account_balance</i><span class=\"link-title\">Überweisung</span></a></li>\n";
|
||||
@ -236,207 +252,228 @@ void CheckTransactionPage::handleRequest(Poco::Net::HTTPServerRequest& request,
|
||||
responseStream << " <li><a href=\"/\" class=\"\"><span class=\"link-title\">Startseite</span></a></li>\n";
|
||||
responseStream << " <li class='nav-content-separator'>-</li>\n";
|
||||
responseStream << " <li class='selected'><span class=\"link-title\">";
|
||||
#line 53 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\header_navi_chr.cpsp"
|
||||
#line 53 "F:\\Gradido\\gradido_login_server_production\\src\\cpsp\\header_navi_chr.cpsp"
|
||||
responseStream << ( pageName );
|
||||
responseStream << "</span></li>\n";
|
||||
responseStream << " </ul>\n";
|
||||
responseStream << " </div>";
|
||||
// end include header_navi_chr.cpsp
|
||||
responseStream << "\n";
|
||||
#line 126 "F:\\Gradido\\gradido_login_server_production\\src\\cpsp\\checkTransaction.cpsp"
|
||||
if(transaction_finalize_run) { responseStream << "\n";
|
||||
responseStream << "<div class=\"col-md-10 equel-grid mb-3\">\n";
|
||||
responseStream << "\t<div class=\"flash-messages\" style=\"background-color: rgba(240,240,240,0.8);\" onclick=\"this.classList.add('hidden')\">\n";
|
||||
responseStream << "\t\t<ul class='grd-no-style'>\n";
|
||||
responseStream << "\t\t\t";
|
||||
#line 130 "F:\\Gradido\\gradido_login_server_production\\src\\cpsp\\checkTransaction.cpsp"
|
||||
if(transaction_finalize_result) { responseStream << " \n";
|
||||
responseStream << "\t\t\t\t<li class='grd-success'>Transaktion erfolgreich</li>\n";
|
||||
responseStream << "\t\t\t";
|
||||
#line 132 "F:\\Gradido\\gradido_login_server_production\\src\\cpsp\\checkTransaction.cpsp"
|
||||
} else { responseStream << "\n";
|
||||
responseStream << "\t\t\t\t<li class='grd-error'>Transaktion fehlgeschlagen</li>\n";
|
||||
responseStream << "\t\t\t";
|
||||
#line 134 "F:\\Gradido\\gradido_login_server_production\\src\\cpsp\\checkTransaction.cpsp"
|
||||
} responseStream << "\n";
|
||||
responseStream << "\t\t</ul>\n";
|
||||
responseStream << "\t</div>\n";
|
||||
responseStream << "</div>\n";
|
||||
#line 138 "F:\\Gradido\\gradido_login_server_production\\src\\cpsp\\checkTransaction.cpsp"
|
||||
} responseStream << "\n";
|
||||
responseStream << "<div class=\"col-md-10 equel-grid mb-3\">\n";
|
||||
responseStream << "\t<small class=\"text-gray d-block mt-3\">\n";
|
||||
responseStream << "\t";
|
||||
#line 112 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 141 "F:\\Gradido\\gradido_login_server_production\\src\\cpsp\\checkTransaction.cpsp"
|
||||
if(sumTransactions > 0 && sumTransactions - notReadyTransactions != 1) { responseStream << "\n";
|
||||
responseStream << "\t\t";
|
||||
#line 113 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 142 "F:\\Gradido\\gradido_login_server_production\\src\\cpsp\\checkTransaction.cpsp"
|
||||
if(notReadyTransactions > 0) { responseStream << " \n";
|
||||
responseStream << "\t\t\t";
|
||||
#line 114 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 143 "F:\\Gradido\\gradido_login_server_production\\src\\cpsp\\checkTransaction.cpsp"
|
||||
responseStream << ( sumTransactions - notReadyTransactions );
|
||||
responseStream << " ";
|
||||
#line 114 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 143 "F:\\Gradido\\gradido_login_server_production\\src\\cpsp\\checkTransaction.cpsp"
|
||||
responseStream << ( gettext("von") );
|
||||
responseStream << " ";
|
||||
#line 114 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 143 "F:\\Gradido\\gradido_login_server_production\\src\\cpsp\\checkTransaction.cpsp"
|
||||
responseStream << ( sumTransactions );
|
||||
responseStream << " ";
|
||||
#line 114 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 143 "F:\\Gradido\\gradido_login_server_production\\src\\cpsp\\checkTransaction.cpsp"
|
||||
responseStream << ( gettext("Transaktionen sind bereit zum bestätigen") );
|
||||
responseStream << "\n";
|
||||
responseStream << "\t\t";
|
||||
#line 115 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 144 "F:\\Gradido\\gradido_login_server_production\\src\\cpsp\\checkTransaction.cpsp"
|
||||
} else { responseStream << "\n";
|
||||
responseStream << "\t\t\t";
|
||||
#line 116 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 145 "F:\\Gradido\\gradido_login_server_production\\src\\cpsp\\checkTransaction.cpsp"
|
||||
responseStream << ( sumTransactions );
|
||||
responseStream << " ";
|
||||
#line 116 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 145 "F:\\Gradido\\gradido_login_server_production\\src\\cpsp\\checkTransaction.cpsp"
|
||||
responseStream << ( gettext("Transaktionen warten darauf bestätigt zu werden.") );
|
||||
responseStream << "\n";
|
||||
responseStream << "\t\t";
|
||||
#line 117 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 146 "F:\\Gradido\\gradido_login_server_production\\src\\cpsp\\checkTransaction.cpsp"
|
||||
} responseStream << "\n";
|
||||
responseStream << "\t";
|
||||
#line 118 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 147 "F:\\Gradido\\gradido_login_server_production\\src\\cpsp\\checkTransaction.cpsp"
|
||||
} responseStream << "\n";
|
||||
responseStream << "\t";
|
||||
#line 119 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 148 "F:\\Gradido\\gradido_login_server_production\\src\\cpsp\\checkTransaction.cpsp"
|
||||
if(state == PAGE_NO_TRANSACTIONS) { responseStream << "\n";
|
||||
responseStream << "\t\t";
|
||||
#line 120 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 149 "F:\\Gradido\\gradido_login_server_production\\src\\cpsp\\checkTransaction.cpsp"
|
||||
if(sumTransactions == 0) { responseStream << "\n";
|
||||
responseStream << "\t\t\t";
|
||||
#line 121 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 150 "F:\\Gradido\\gradido_login_server_production\\src\\cpsp\\checkTransaction.cpsp"
|
||||
responseStream << ( gettext("Es gibt zurzeit keine Transaktionen zum bestätigen") );
|
||||
responseStream << "\n";
|
||||
responseStream << "\t\t";
|
||||
#line 122 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 151 "F:\\Gradido\\gradido_login_server_production\\src\\cpsp\\checkTransaction.cpsp"
|
||||
} else { responseStream << "\n";
|
||||
responseStream << "\t\t\t";
|
||||
#line 123 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 152 "F:\\Gradido\\gradido_login_server_production\\src\\cpsp\\checkTransaction.cpsp"
|
||||
responseStream << ( gettext("Transaktion(en) werden noch vorbereitet, bitte lade die Seite in wenigen Augenblicken erneut.") );
|
||||
responseStream << "\n";
|
||||
responseStream << "\t\t";
|
||||
#line 124 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 153 "F:\\Gradido\\gradido_login_server_production\\src\\cpsp\\checkTransaction.cpsp"
|
||||
} responseStream << "\n";
|
||||
responseStream << " ";
|
||||
#line 125 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 154 "F:\\Gradido\\gradido_login_server_production\\src\\cpsp\\checkTransaction.cpsp"
|
||||
} responseStream << "\n";
|
||||
responseStream << "\t</small>\n";
|
||||
responseStream << "</div>\n";
|
||||
responseStream << "<div class=\"content-container main-container\">\n";
|
||||
responseStream << "\t<div class=\"action-form\">\n";
|
||||
responseStream << "\t\t<p class=\"form-header\">";
|
||||
#line 130 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 159 "F:\\Gradido\\gradido_login_server_production\\src\\cpsp\\checkTransaction.cpsp"
|
||||
responseStream << ( gettext("Transaktion Unterzeichnen") );
|
||||
responseStream << "</p>\n";
|
||||
responseStream << "\t\t<div class=\"form-content\">\n";
|
||||
responseStream << "\t\t";
|
||||
#line 132 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 161 "F:\\Gradido\\gradido_login_server_production\\src\\cpsp\\checkTransaction.cpsp"
|
||||
if(state == PAGE_TRANSACTION_TRANSFER) {
|
||||
auto transferTransaction = processingTransaction->getTransferTransaction();
|
||||
memo = transferTransaction->getMemo();
|
||||
responseStream << "\n";
|
||||
responseStream << "\t\t\t<p>";
|
||||
#line 136 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 165 "F:\\Gradido\\gradido_login_server_production\\src\\cpsp\\checkTransaction.cpsp"
|
||||
responseStream << ( gettext("Überweisung") );
|
||||
responseStream << "</p>\n";
|
||||
responseStream << "\t\t\t<div class=\"content-table\">\n";
|
||||
responseStream << "\t\t\t <div class=\"content-row content-row-header\">\n";
|
||||
responseStream << "\t\t\t\t<span class=\"content-cell\">";
|
||||
#line 139 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 168 "F:\\Gradido\\gradido_login_server_production\\src\\cpsp\\checkTransaction.cpsp"
|
||||
responseStream << ( gettext("Konto") );
|
||||
responseStream << "</span>\n";
|
||||
responseStream << "\t\t\t\t<span class=\"content-cell\">";
|
||||
#line 140 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 169 "F:\\Gradido\\gradido_login_server_production\\src\\cpsp\\checkTransaction.cpsp"
|
||||
responseStream << ( gettext("Gradido") );
|
||||
responseStream << "</span>\n";
|
||||
responseStream << "\t\t\t </div>\n";
|
||||
responseStream << "\t\t\t ";
|
||||
#line 142 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 171 "F:\\Gradido\\gradido_login_server_production\\src\\cpsp\\checkTransaction.cpsp"
|
||||
for(int i = 0; i < transferTransaction->getKontoTableSize(); i++) { responseStream << "\t\t\t\t\t\n";
|
||||
responseStream << "\t\t\t\t\t";
|
||||
#line 143 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 172 "F:\\Gradido\\gradido_login_server_production\\src\\cpsp\\checkTransaction.cpsp"
|
||||
if((i+1) % 2 == 0) { responseStream << "\n";
|
||||
responseStream << "\t\t\t\t\t\t<div class=\"content-row content-row\">\n";
|
||||
responseStream << "\t\t\t\t\t";
|
||||
#line 145 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 174 "F:\\Gradido\\gradido_login_server_production\\src\\cpsp\\checkTransaction.cpsp"
|
||||
} else { responseStream << "\n";
|
||||
responseStream << "\t\t\t\t\t\t<div class=\"content-row content-row-bg\">\n";
|
||||
responseStream << "\t\t\t\t\t";
|
||||
#line 147 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 176 "F:\\Gradido\\gradido_login_server_production\\src\\cpsp\\checkTransaction.cpsp"
|
||||
} responseStream << "\n";
|
||||
responseStream << "\t\t\t\t\t\t";
|
||||
#line 148 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 177 "F:\\Gradido\\gradido_login_server_production\\src\\cpsp\\checkTransaction.cpsp"
|
||||
responseStream << ( transferTransaction->getKontoNameCell(i) );
|
||||
responseStream << "\n";
|
||||
responseStream << "\t\t\t\t\t\t";
|
||||
#line 149 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 178 "F:\\Gradido\\gradido_login_server_production\\src\\cpsp\\checkTransaction.cpsp"
|
||||
responseStream << ( transferTransaction->getAmountCell(i) );
|
||||
responseStream << "\n";
|
||||
responseStream << "\t\t\t\t\t</div>\n";
|
||||
responseStream << "\t\t\t ";
|
||||
#line 151 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 180 "F:\\Gradido\\gradido_login_server_production\\src\\cpsp\\checkTransaction.cpsp"
|
||||
} responseStream << "\n";
|
||||
responseStream << "\t\t\t</div>\n";
|
||||
responseStream << "\t\t\t ";
|
||||
#line 153 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 182 "F:\\Gradido\\gradido_login_server_production\\src\\cpsp\\checkTransaction.cpsp"
|
||||
} else if(PAGE_TRANSACTION_CREATION == state) {
|
||||
auto creationTransaction = processingTransaction->getCreationTransaction();
|
||||
auto transactionUser = creationTransaction->getUser();
|
||||
memo = creationTransaction->getMemo();
|
||||
responseStream << "\n";
|
||||
responseStream << "\t\t\t\t<p>";
|
||||
#line 158 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 187 "F:\\Gradido\\gradido_login_server_production\\src\\cpsp\\checkTransaction.cpsp"
|
||||
responseStream << ( gettext("Schöpfung") );
|
||||
responseStream << "</p>\n";
|
||||
responseStream << "\t\t\t\t<div class=\"content-table\">\n";
|
||||
responseStream << "\t\t\t\t <div class=\"content-row content-row-header\">\n";
|
||||
responseStream << "\t\t\t\t\t<span class=\"content-cell\">";
|
||||
#line 161 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 190 "F:\\Gradido\\gradido_login_server_production\\src\\cpsp\\checkTransaction.cpsp"
|
||||
responseStream << ( gettext("Konto") );
|
||||
responseStream << "</span>\n";
|
||||
responseStream << "\t\t\t\t\t<span class=\"content-cell\">";
|
||||
#line 162 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 191 "F:\\Gradido\\gradido_login_server_production\\src\\cpsp\\checkTransaction.cpsp"
|
||||
responseStream << ( gettext("Zieldatum") );
|
||||
responseStream << "</span>\n";
|
||||
responseStream << "\t\t\t\t\t<span class=\"content-cell\">";
|
||||
#line 163 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 192 "F:\\Gradido\\gradido_login_server_production\\src\\cpsp\\checkTransaction.cpsp"
|
||||
responseStream << ( gettext("Gradido") );
|
||||
responseStream << "</span>\n";
|
||||
responseStream << "\t\t\t\t </div>\n";
|
||||
responseStream << "\t\t\t\t <div class=\"content-row content-row-bg\">\n";
|
||||
responseStream << "\t\t\t\t\t";
|
||||
#line 166 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 195 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
if(!transactionUser.isNull()) {
|
||||
auto user_model = transactionUser->getModel();
|
||||
responseStream << "\n";
|
||||
auto user_model = transactionUser->getModel();
|
||||
responseStream << "\n";
|
||||
responseStream << "\t\t\t\t\t\t<span class=\"content-cell\">";
|
||||
#line 169 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 196 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
responseStream << ( user_model->getFirstName() );
|
||||
responseStream << " ";
|
||||
#line 169 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 196 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
responseStream << ( user_model->getLastName() );
|
||||
responseStream << " <";
|
||||
#line 169 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 196 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
responseStream << ( user_model->getEmail() );
|
||||
responseStream << "></span>\n";
|
||||
responseStream << "\t\t\t\t\t";
|
||||
#line 170 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 197 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
} else { responseStream << "\n";
|
||||
responseStream << "\t\t\t\t\t\t<span class=\"content-cell\">0x";
|
||||
#line 171 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 198 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
responseStream << ( creationTransaction->getPublicHex() );
|
||||
responseStream << "</span>\n";
|
||||
responseStream << "\t\t\t\t\t";
|
||||
#line 172 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 199 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
} responseStream << "\n";
|
||||
responseStream << "\t\t\t\t\t<span class=\"content-cell\">";
|
||||
#line 173 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 200 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
responseStream << ( creationTransaction->getTargetDateString() );
|
||||
responseStream << "</span>\n";
|
||||
responseStream << "\t\t\t\t\t<span class=\"content-cell success-color\">";
|
||||
#line 174 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 201 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
responseStream << ( creationTransaction->getAmountString() );
|
||||
responseStream << " GDD</span>\n";
|
||||
responseStream << "\t\t\t\t </div>\n";
|
||||
responseStream << "\t\t\t\t</div>\n";
|
||||
responseStream << "\t\t\t ";
|
||||
#line 177 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 204 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
} else if(PAGE_USER_DATA_CORRUPTED == state) { responseStream << "\n";
|
||||
responseStream << "\t\t\t\t<p class=\"alert-color\">";
|
||||
#line 178 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 205 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
responseStream << ( gettext("Es gibt ein Problem mit deinen gespeicherten Daten, bitte wende dich an den"));
|
||||
responseStream << "<a href=\"mailto:";
|
||||
#line 178 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 205 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
responseStream << ( em->getAdminReceiver());
|
||||
responseStream << "?subject=Corrupt User Data&body=Hallo Dario,%0D%0A%0D%0Ameine Benutzer Daten sind korrupt.%0D%0Akannst du das prüfen?%0D%0A%0D%0AMit freundlichen Grüßen%0D%0A\">";
|
||||
#line 178 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 205 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
responseStream << (gettext("Support") );
|
||||
responseStream << "</a></p>\n";
|
||||
responseStream << "\t\t\t ";
|
||||
#line 179 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 206 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
} responseStream << "\n";
|
||||
responseStream << "\t\t\t<div class=\"content-table\">\n";
|
||||
responseStream << "\t\t\t <div class=\"content-row content-row-header\">\n";
|
||||
@ -444,7 +481,7 @@ void CheckTransactionPage::handleRequest(Poco::Net::HTTPServerRequest& request,
|
||||
responseStream << "\t\t\t </div>\n";
|
||||
responseStream << "\t\t\t <div class=\"content-row\">\n";
|
||||
responseStream << "\t\t\t\t<span class=\"content-cell\">";
|
||||
#line 185 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 212 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
responseStream << ( user_model->getNameWithEmailHtml() );
|
||||
responseStream << "</span>\n";
|
||||
responseStream << "\t\t\t </div>\n";
|
||||
@ -455,48 +492,58 @@ void CheckTransactionPage::handleRequest(Poco::Net::HTTPServerRequest& request,
|
||||
responseStream << "\t\t\t </div>\n";
|
||||
responseStream << "\t\t\t <div class=\"content-row content-row-bg\">\n";
|
||||
responseStream << "\t\t\t\t<span class=\"content-cell\">";
|
||||
#line 193 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 220 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
responseStream << ( memo );
|
||||
responseStream << "</span>\n";
|
||||
responseStream << "\t\t\t </div>\n";
|
||||
responseStream << "\t\t\t</div>\n";
|
||||
responseStream << "\t\t\t<form>\n";
|
||||
responseStream << "\t\t\t\t";
|
||||
#line 197 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 224 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
if(!account_user->hasPassword()) { responseStream << "\n";
|
||||
responseStream << "\t\t\t\t <div class=\"form-group\">\n";
|
||||
responseStream << "\t\t\t\t\t <label for=\"sign-password\">";
|
||||
#line 199 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 226 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
responseStream << ( gettext("Ich brauche nochmal dein Passwort") );
|
||||
responseStream << "</label>\n";
|
||||
responseStream << "\t\t\t\t\t <input type=\"password\" class=\"form-control\" id=\"sign-password\" name=\"sign-password\" placeholder=\"";
|
||||
#line 200 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 227 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
responseStream << ( gettext("Passwort") );
|
||||
responseStream << "\">\n";
|
||||
responseStream << "\t\t\t\t </div>\n";
|
||||
responseStream << "\t\t\t\t";
|
||||
#line 202 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 229 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
} responseStream << "\n";
|
||||
responseStream << "\t\t\t\t";
|
||||
#line 203 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 230 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
if(PAGE_USER_DATA_CORRUPTED != state && user_model->isEmailChecked()) { responseStream << "\n";
|
||||
responseStream << "\t\t\t\t\t<button type=\"submit\" class=\"form-button\" name=\"ok\" value=\"ok\">\n";
|
||||
responseStream << "\t\t\t\t\t\t<i class=\"material-icons-outlined\">verified_user</i>\n";
|
||||
responseStream << "\t\t\t\t\t\t";
|
||||
#line 206 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 233 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
responseStream << ( gettext("Transaktion unterzeichnen") );
|
||||
responseStream << "\n";
|
||||
responseStream << "\t\t\t\t\t</button>\n";
|
||||
responseStream << "\t\t\t\t";
|
||||
#line 208 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 235 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
} responseStream << "\n";
|
||||
responseStream << "\t\t\t\t<button type=\"submit\" class=\"form-button button-cancel\" name=\"abort\" value=\"abort\">\n";
|
||||
responseStream << "\t\t\t\t\t<i class=\"material-icons-outlined\">delete</i>\n";
|
||||
responseStream << "\t\t\t\t\t";
|
||||
#line 211 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
#line 238 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\checkTransaction.cpsp"
|
||||
responseStream << ( gettext("Transaktion verwerfen") );
|
||||
responseStream << "\n";
|
||||
responseStream << "\t\t\t\t</button>\n";
|
||||
responseStream << "\t\t\t\t";
|
||||
#line 240 "F:\\Gradido\\gradido_login_server_production\\src\\cpsp\\checkTransaction.cpsp"
|
||||
if(sumTransactions == 0) { responseStream << "\n";
|
||||
responseStream << "\t\t\t\t\t<button type=\"submit\" class=\"form-button button-cancel\" name=\"back\" value=\"back\">\n";
|
||||
responseStream << "\t\t\t\t\t\t<i class=\"material-icons-outlined\">back</i>\n";
|
||||
responseStream << "\t\t\t\t\t\tZurück\n";
|
||||
responseStream << "\t\t\t\t\t</button>\t\n";
|
||||
responseStream << "\t\t\t\t";
|
||||
#line 245 "F:\\Gradido\\gradido_login_server_production\\src\\cpsp\\checkTransaction.cpsp"
|
||||
} responseStream << "\n";
|
||||
responseStream << "\t\t\t</form>\n";
|
||||
responseStream << "\t\t</div>\n";
|
||||
responseStream << "\t</div>\n";
|
||||
@ -515,14 +562,14 @@ void CheckTransactionPage::handleRequest(Poco::Net::HTTPServerRequest& request,
|
||||
responseStream << " </div>\n";
|
||||
responseStream << " <div class=\"bottomleft\">\n";
|
||||
responseStream << " ";
|
||||
#line 13 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\footer_chr.cpsp"
|
||||
#line 13 "F:\\Gradido\\gradido_login_server_production\\src\\cpsp\\footer_chr.cpsp"
|
||||
responseStream << ( mTimeProfiler.string() );
|
||||
responseStream << "\n";
|
||||
responseStream << " </div>\n";
|
||||
responseStream << " <div class=\"bottomright\">\n";
|
||||
responseStream << " <p>Community Server in Entwicklung</p>\n";
|
||||
responseStream << " <p>Alpha ";
|
||||
#line 17 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\footer_chr.cpsp"
|
||||
#line 17 "F:\\Gradido\\gradido_login_server_production\\src\\cpsp\\footer_chr.cpsp"
|
||||
responseStream << ( ServerConfig::g_versionString );
|
||||
responseStream << "</p>\n";
|
||||
responseStream << " </div>\n";
|
||||
|
||||
@ -5,13 +5,14 @@
|
||||
#include "Poco/DeflatingStream.h"
|
||||
|
||||
|
||||
#line 7 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\decodeTransaction.cpsp"
|
||||
#line 7 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\decodeTransaction.cpsp"
|
||||
|
||||
#include "sodium.h"
|
||||
#include "../proto/gradido/TransactionBody.pb.h"
|
||||
#include "../controller/User.h"
|
||||
#include "../model/TransactionBase.h"
|
||||
#line 1 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\header_old.cpsp"
|
||||
#include "../model/TransactionCreation.h"
|
||||
#line 1 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\header_old.cpsp"
|
||||
|
||||
#include "../ServerConfig.h"
|
||||
|
||||
@ -30,7 +31,7 @@ void DecodeTransactionPage::handleRequest(Poco::Net::HTTPServerRequest& request,
|
||||
if (_compressResponse) response.set("Content-Encoding", "gzip");
|
||||
|
||||
Poco::Net::HTMLForm form(request, request.stream());
|
||||
#line 13 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\decodeTransaction.cpsp"
|
||||
#line 14 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\decodeTransaction.cpsp"
|
||||
|
||||
const char* pageName = "Decode Transaction";
|
||||
proto::gradido::TransactionBody transactionBody;
|
||||
@ -98,12 +99,12 @@ void DecodeTransactionPage::handleRequest(Poco::Net::HTTPServerRequest& request,
|
||||
responseStream << "<meta charset=\"UTF-8\">\n";
|
||||
responseStream << "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n";
|
||||
responseStream << "<title>Gradido Login Server: ";
|
||||
#line 9 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\header_old.cpsp"
|
||||
#line 9 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\header_old.cpsp"
|
||||
responseStream << ( pageName );
|
||||
responseStream << "</title>\n";
|
||||
responseStream << "<!--<link rel=\"stylesheet\" type=\"text/css\" href=\"css/styles.min.css\">-->\n";
|
||||
responseStream << "<link rel=\"stylesheet\" type=\"text/css\" href=\"";
|
||||
#line 11 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\header_old.cpsp"
|
||||
#line 11 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\header_old.cpsp"
|
||||
responseStream << ( ServerConfig::g_php_serverPath );
|
||||
responseStream << "/css/styles.css\">\n";
|
||||
responseStream << "<style type=\"text/css\" >\n";
|
||||
@ -148,7 +149,7 @@ void DecodeTransactionPage::handleRequest(Poco::Net::HTTPServerRequest& request,
|
||||
responseStream << "<div class=\"versionstring dev-info\">\n";
|
||||
responseStream << "\t<p class=\"grd_small\">Login Server in Entwicklung</p>\n";
|
||||
responseStream << "\t<p class=\"grd_small\">Alpha ";
|
||||
#line 53 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\header_old.cpsp"
|
||||
#line 53 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\header_old.cpsp"
|
||||
responseStream << ( ServerConfig::g_versionString );
|
||||
responseStream << "</p>\n";
|
||||
responseStream << "</div>\n";
|
||||
@ -157,35 +158,35 @@ void DecodeTransactionPage::handleRequest(Poco::Net::HTTPServerRequest& request,
|
||||
responseStream << "<div class=\"grd_container\">\n";
|
||||
responseStream << "\t<h1>Transaktion dekodieren</h1>\n";
|
||||
responseStream << "\t";
|
||||
#line 71 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\decodeTransaction.cpsp"
|
||||
#line 72 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\decodeTransaction.cpsp"
|
||||
responseStream << ( getErrorsHtml() );
|
||||
responseStream << "\n";
|
||||
responseStream << "\t<form method=\"POST\">\n";
|
||||
responseStream << "\t\t<fieldset class=\"grd_container_small\">\n";
|
||||
responseStream << "\t\t\t<legend>Transaktion dekodieren</legend>\n";
|
||||
responseStream << "\t\t\t<textarea style=\"width:100%;height:100px\" name=\"transaction\">";
|
||||
#line 75 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\decodeTransaction.cpsp"
|
||||
#line 76 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\decodeTransaction.cpsp"
|
||||
responseStream << ( !form.empty() ? form.get("transaction", "") : "" );
|
||||
responseStream << "</textarea>\n";
|
||||
responseStream << "\t\t</fieldset>\n";
|
||||
responseStream << "\t\t<input class=\"grd-form-bn grd-form-bn-succeed\" type=\"submit\" name=\"submit\" value=\"Dekodieren\">\n";
|
||||
responseStream << "\t</form>\n";
|
||||
responseStream << "\t";
|
||||
#line 79 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\decodeTransaction.cpsp"
|
||||
#line 80 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\decodeTransaction.cpsp"
|
||||
if(decoded) { responseStream << "\n";
|
||||
responseStream << "\t\t<p><b>Verwendungszweck:</b></p>\n";
|
||||
responseStream << "\t\t<p>";
|
||||
#line 81 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\decodeTransaction.cpsp"
|
||||
#line 82 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\decodeTransaction.cpsp"
|
||||
responseStream << ( transactionBody.memo() );
|
||||
responseStream << "</p>\n";
|
||||
responseStream << "\t\t";
|
||||
#line 82 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\decodeTransaction.cpsp"
|
||||
#line 83 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\decodeTransaction.cpsp"
|
||||
if(transactionBody.has_transfer()) {
|
||||
auto transfer = transactionBody.transfer();
|
||||
char hex[65]; memset(hex, 0, 65);
|
||||
responseStream << "\n";
|
||||
responseStream << "\t\t\t";
|
||||
#line 86 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\decodeTransaction.cpsp"
|
||||
#line 87 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\decodeTransaction.cpsp"
|
||||
if(transfer.has_local()) {
|
||||
auto local_transfer = transfer.local();
|
||||
auto sender_pubkey = local_transfer.sender().pubkey();
|
||||
@ -194,31 +195,33 @@ void DecodeTransactionPage::handleRequest(Poco::Net::HTTPServerRequest& request,
|
||||
responseStream << "\n";
|
||||
responseStream << "\t\t\t\t<h3>Local Transfer</h3>\n";
|
||||
responseStream << "\t\t\t\t<b>From: </b>";
|
||||
#line 93 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\decodeTransaction.cpsp"
|
||||
#line 94 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\decodeTransaction.cpsp"
|
||||
responseStream << ( hex );
|
||||
responseStream << "\n";
|
||||
responseStream << "\t\t\t\t";
|
||||
#line 94 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\decodeTransaction.cpsp"
|
||||
#line 95 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\decodeTransaction.cpsp"
|
||||
sodium_bin2hex(hex, 65, (const unsigned char*)receiver_pubkey.data(), receiver_pubkey.size()); responseStream << "\n";
|
||||
responseStream << "\t\t\t\t<b>To: </b>";
|
||||
#line 95 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\decodeTransaction.cpsp"
|
||||
#line 96 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\decodeTransaction.cpsp"
|
||||
responseStream << ( hex );
|
||||
responseStream << "\n";
|
||||
responseStream << "\t\t\t\t<b>Amount: </b>";
|
||||
#line 96 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\decodeTransaction.cpsp"
|
||||
#line 97 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\decodeTransaction.cpsp"
|
||||
responseStream << ( TransactionBase::amountToString(local_transfer.sender().amount()) );
|
||||
responseStream << "\n";
|
||||
responseStream << "\t\t\t";
|
||||
#line 97 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\decodeTransaction.cpsp"
|
||||
#line 98 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\decodeTransaction.cpsp"
|
||||
} else { responseStream << "\n";
|
||||
responseStream << "\t\t\t\t<h3>- Not implemented yet (Group Transfer) -</h3>\n";
|
||||
responseStream << "\t\t\t";
|
||||
#line 99 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\decodeTransaction.cpsp"
|
||||
#line 100 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\decodeTransaction.cpsp"
|
||||
} responseStream << "\n";
|
||||
responseStream << "\t\t";
|
||||
#line 101 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\decodeTransaction.cpsp"
|
||||
#line 102 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\decodeTransaction.cpsp"
|
||||
} else if(transactionBody.has_creation()) {
|
||||
auto creation = transactionBody.creation();
|
||||
|
||||
TransactionCreation creationObject("", creation);
|
||||
auto receiver = creation.receiver();
|
||||
char hex[65]; memset(hex, 0, 65);
|
||||
sodium_bin2hex(hex, 65, (const unsigned char*)receiver.pubkey().data(), receiver.pubkey().size());
|
||||
@ -234,32 +237,36 @@ void DecodeTransactionPage::handleRequest(Poco::Net::HTTPServerRequest& request,
|
||||
responseStream << "\n";
|
||||
responseStream << "\t\t<h3>Creation</h3>\n";
|
||||
responseStream << "\t\t";
|
||||
#line 117 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\decodeTransaction.cpsp"
|
||||
#line 120 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\decodeTransaction.cpsp"
|
||||
if(!adminUser || user.isNull() || !user->getModel()) { responseStream << "\n";
|
||||
responseStream << "\t\t<p>pubkey: ";
|
||||
#line 118 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\decodeTransaction.cpsp"
|
||||
#line 121 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\decodeTransaction.cpsp"
|
||||
responseStream << ( hex );
|
||||
responseStream << "</p>\n";
|
||||
responseStream << "\t\t";
|
||||
#line 119 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\decodeTransaction.cpsp"
|
||||
#line 122 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\decodeTransaction.cpsp"
|
||||
} else { responseStream << "\n";
|
||||
responseStream << "\t\t<p>user: </p>\n";
|
||||
responseStream << "\t\t<p>";
|
||||
#line 121 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\decodeTransaction.cpsp"
|
||||
#line 124 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\decodeTransaction.cpsp"
|
||||
responseStream << ( user->getModel()->toHTMLString() );
|
||||
responseStream << "</p>\n";
|
||||
responseStream << "\t\t";
|
||||
#line 122 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\decodeTransaction.cpsp"
|
||||
#line 125 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\decodeTransaction.cpsp"
|
||||
} responseStream << "\n";
|
||||
responseStream << "\t\t<p>amount: ";
|
||||
#line 123 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\decodeTransaction.cpsp"
|
||||
#line 126 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\decodeTransaction.cpsp"
|
||||
responseStream << ( TransactionBase::amountToString(receiver.amount()) );
|
||||
responseStream << " GDD</p>\n";
|
||||
responseStream << "\t\t<p>target date: ";
|
||||
#line 127 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\decodeTransaction.cpsp"
|
||||
responseStream << ( creationObject.getTargetDateString() );
|
||||
responseStream << "</p>\n";
|
||||
responseStream << "\t\t";
|
||||
#line 124 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\decodeTransaction.cpsp"
|
||||
#line 128 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\decodeTransaction.cpsp"
|
||||
} responseStream << "\n";
|
||||
responseStream << "\t";
|
||||
#line 125 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\decodeTransaction.cpsp"
|
||||
#line 129 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\decodeTransaction.cpsp"
|
||||
} responseStream << "\n";
|
||||
responseStream << "</div>\n";
|
||||
// begin include footer.cpsp
|
||||
@ -269,14 +276,14 @@ void DecodeTransactionPage::handleRequest(Poco::Net::HTTPServerRequest& request,
|
||||
responseStream << " </div>\n";
|
||||
responseStream << " <div class=\"bottomleft\">\n";
|
||||
responseStream << " ";
|
||||
#line 6 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\footer.cpsp"
|
||||
#line 6 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\footer.cpsp"
|
||||
responseStream << ( mTimeProfiler.string() );
|
||||
responseStream << "\n";
|
||||
responseStream << " </div>\n";
|
||||
responseStream << " <div class=\"bottomright\">\n";
|
||||
responseStream << " <p>Login Server in Entwicklung</p>\n";
|
||||
responseStream << " <p>Alpha ";
|
||||
#line 10 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\footer.cpsp"
|
||||
#line 10 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\footer.cpsp"
|
||||
responseStream << ( ServerConfig::g_versionString );
|
||||
responseStream << "</p>\n";
|
||||
responseStream << " </div>\n";
|
||||
|
||||
@ -117,6 +117,7 @@ void ElopageWebhook::handleRequest(Poco::Net::HTTPServerRequest& request, Poco::
|
||||
// check event type
|
||||
std::string event = elopageRequestData.get("event", "");
|
||||
if (event == "lesson.viewed") {
|
||||
printf("elopage request was lesson viewed\n");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -144,7 +145,7 @@ void ElopageWebhook::handleRequest(Poco::Net::HTTPServerRequest& request, Poco::
|
||||
file << std::endl;
|
||||
file.close();
|
||||
std::string timeUsedStr = timeUsed.string();
|
||||
printf("[%s] time for elopage request write to file and maybe wait on lock: %s\n", dateTimeStr.data(), timeUsedStr.data());
|
||||
printf("[%s] time for elopage request write to file: %s\n", dateTimeStr.data(), timeUsedStr.data());
|
||||
mutex.unlock();
|
||||
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
#include "Poco/DeflatingStream.h"
|
||||
|
||||
|
||||
#line 7 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\login.cpsp"
|
||||
#line 7 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\login.cpsp"
|
||||
|
||||
#include "../gettext.h"
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
#include "../SingletonManager/LanguageManager.h"
|
||||
#include "../SingletonManager/ErrorManager.h"
|
||||
|
||||
#line 1 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\header.cpsp"
|
||||
#line 1 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\header.cpsp"
|
||||
|
||||
#include "../ServerConfig.h"
|
||||
|
||||
@ -35,7 +35,7 @@ void LoginPage::handleRequest(Poco::Net::HTTPServerRequest& request, Poco::Net::
|
||||
if (_compressResponse) response.set("Content-Encoding", "gzip");
|
||||
|
||||
Poco::Net::HTMLForm form(request, request.stream());
|
||||
#line 18 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\login.cpsp"
|
||||
#line 18 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\login.cpsp"
|
||||
|
||||
const char* pageName = "Login";
|
||||
auto sm = SessionManager::getInstance();
|
||||
@ -50,7 +50,12 @@ void LoginPage::handleRequest(Poco::Net::HTTPServerRequest& request, Poco::Net::
|
||||
if(mSession && mSession->getNewUser()) {
|
||||
presetEmail = mSession->getNewUser()->getModel()->getEmail();
|
||||
}
|
||||
|
||||
/*
|
||||
if(mSession && mSession->getUser()) {
|
||||
presetEmail = mSession->getUser()->getEmail();
|
||||
}
|
||||
*/
|
||||
|
||||
if(!form.empty()) {
|
||||
|
||||
bool langUpdatedByBtn = false;
|
||||
@ -85,8 +90,12 @@ void LoginPage::handleRequest(Poco::Net::HTTPServerRequest& request, Poco::Net::
|
||||
// get language
|
||||
// first check url, second check language header
|
||||
// for debugging client ip
|
||||
auto client_ip = request.clientAddress();
|
||||
auto client_host = request.clientAddress().host();
|
||||
//auto client_ip = request.clientAddress();
|
||||
// X-Real-IP forwarded ip from nginx config
|
||||
auto client_host_string = request.get("X-Real-IP", client_host.toString());
|
||||
std::string clientIpString = "client ip: ";
|
||||
client_host = Poco::Net::IPAddress(client_host_string);
|
||||
clientIpString += client_ip.toString();
|
||||
Poco::Logger::get("requestLog").information(clientIpString);
|
||||
// debugging end
|
||||
@ -96,14 +105,21 @@ void LoginPage::handleRequest(Poco::Net::HTTPServerRequest& request, Poco::Net::
|
||||
} else {
|
||||
langCatalog = mSession->getLanguageCatalog();
|
||||
}
|
||||
auto userState = mSession->loadUser(email, password);
|
||||
UserState user_state;
|
||||
try {
|
||||
user_state = mSession->loadUser(email, password);
|
||||
} catch (Poco::Exception& ex) {
|
||||
addError(new ParamError("login", "exception by calling loadUser: ", ex.displayText()));
|
||||
sendErrorsAsEmail();
|
||||
addError(new Error("Error", "Intern Server error, please try again later"));
|
||||
}
|
||||
auto user = mSession->getNewUser();
|
||||
|
||||
if(userState >= USER_LOADED_FROM_DB && !user->getModel()->getPublicKey()) {
|
||||
if(user_state >= USER_LOADED_FROM_DB && !user->getModel()->getPublicKey()) {
|
||||
if(mSession->generateKeys(true, true)) {
|
||||
userState = USER_COMPLETE;
|
||||
user_state = USER_COMPLETE;
|
||||
if(user->getModel()->isDisabled()) {
|
||||
userState = USER_DISABLED;
|
||||
user_state = USER_DISABLED;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -114,12 +130,17 @@ void LoginPage::handleRequest(Poco::Net::HTTPServerRequest& request, Poco::Net::
|
||||
auto uri_start = request.serverParams().getServerName();
|
||||
auto lastExternReferer = mSession->getLastReferer();
|
||||
|
||||
//printf("userState: %d\n", userState);
|
||||
printf("user_state: %d\n", user_state);
|
||||
|
||||
switch(userState) {
|
||||
switch(user_state) {
|
||||
case USER_EMPTY:
|
||||
case USER_PASSWORD_INCORRECT:
|
||||
addError(new Error(langCatalog->gettext("Login"), langCatalog->gettext("E-Mail or password isn't right, please try again!")), false);
|
||||
if(mSession) {
|
||||
getErrors(mSession);
|
||||
sm->releaseSession(mSession);
|
||||
}
|
||||
sm->deleteLoginCookies(request, response);
|
||||
break;
|
||||
case USER_PASSWORD_ENCRYPTION_IN_PROCESS:
|
||||
addError(new Error(langCatalog->gettext("Passwort"), langCatalog->gettext("Passwort wird noch berechnet, bitte versuche es in etwa 1 Minute erneut.")), false);
|
||||
@ -180,7 +201,7 @@ void LoginPage::handleRequest(Poco::Net::HTTPServerRequest& request, Poco::Net::
|
||||
sm->deleteLoginCookies(request, response);
|
||||
}
|
||||
|
||||
#line 3 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\header.cpsp"
|
||||
#line 3 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\header.cpsp"
|
||||
|
||||
bool withMaterialIcons = false;
|
||||
std::ostream& _responseStream = response.send();
|
||||
@ -195,20 +216,20 @@ void LoginPage::handleRequest(Poco::Net::HTTPServerRequest& request, Poco::Net::
|
||||
responseStream << "<meta charset=\"UTF-8\">\n";
|
||||
responseStream << "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1, shrink-to-fit=no\">\n";
|
||||
responseStream << "<title>Gradido Login Server: ";
|
||||
#line 11 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\header.cpsp"
|
||||
#line 11 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\header.cpsp"
|
||||
responseStream << ( pageName );
|
||||
responseStream << "</title>\n";
|
||||
responseStream << "<link rel=\"stylesheet\" type=\"text/css\" href=\"";
|
||||
#line 12 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\header.cpsp"
|
||||
#line 12 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\header.cpsp"
|
||||
responseStream << ( ServerConfig::g_php_serverPath );
|
||||
responseStream << "css/main.css\">\n";
|
||||
#line 13 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\header.cpsp"
|
||||
#line 13 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\header.cpsp"
|
||||
if(withMaterialIcons) { responseStream << "\n";
|
||||
responseStream << "<link rel=\"stylesheet\" type=\"text/css\" href=\"";
|
||||
#line 14 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\header.cpsp"
|
||||
#line 14 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\header.cpsp"
|
||||
responseStream << ( ServerConfig::g_php_serverPath );
|
||||
responseStream << "css/materialdesignicons.min.css\">\n";
|
||||
#line 15 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\header.cpsp"
|
||||
#line 15 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\header.cpsp"
|
||||
} responseStream << "\n";
|
||||
responseStream << "</head>\n";
|
||||
responseStream << "<body>\n";
|
||||
@ -216,20 +237,20 @@ void LoginPage::handleRequest(Poco::Net::HTTPServerRequest& request, Poco::Net::
|
||||
responseStream << " <div class=\"center-form-single\">\n";
|
||||
responseStream << " <div class=\"center-form-header\">\n";
|
||||
responseStream << " <a href=\"";
|
||||
#line 21 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\header.cpsp"
|
||||
#line 21 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\header.cpsp"
|
||||
responseStream << ( ServerConfig::g_php_serverPath );
|
||||
responseStream << "\" class=\"center-logo\">\n";
|
||||
responseStream << " <picture>\n";
|
||||
responseStream << " <source srcset=\"";
|
||||
#line 23 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\header.cpsp"
|
||||
#line 23 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\header.cpsp"
|
||||
responseStream << ( ServerConfig::g_php_serverPath );
|
||||
responseStream << "img/logo_schrift.webp\" type=\"image/webp\">\n";
|
||||
responseStream << " <source srcset=\"";
|
||||
#line 24 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\header.cpsp"
|
||||
#line 24 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\header.cpsp"
|
||||
responseStream << ( ServerConfig::g_php_serverPath );
|
||||
responseStream << "img/logo_schrift.png\" type=\"image/png\">\n";
|
||||
responseStream << " <img src=\"";
|
||||
#line 25 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\header.cpsp"
|
||||
#line 25 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\header.cpsp"
|
||||
responseStream << ( ServerConfig::g_php_serverPath );
|
||||
responseStream << "img/logo_schrift.png\" alt=\"logo\" />\n";
|
||||
responseStream << " </picture>\n";
|
||||
@ -237,11 +258,11 @@ void LoginPage::handleRequest(Poco::Net::HTTPServerRequest& request, Poco::Net::
|
||||
responseStream << " </div>";
|
||||
// end include header.cpsp
|
||||
responseStream << "\n";
|
||||
#line 163 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\login.cpsp"
|
||||
#line 170 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\login.cpsp"
|
||||
responseStream << ( getErrorsHtml() );
|
||||
responseStream << "\n";
|
||||
responseStream << "<!--<input type=\"hidden\" name=\"lang\" value=\"";
|
||||
#line 164 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\login.cpsp"
|
||||
#line 171 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\login.cpsp"
|
||||
responseStream << ( LanguageManager::keyForLanguage(lang) );
|
||||
responseStream << "\">-->\n";
|
||||
responseStream << "<div class=\"center-form-container\">\n";
|
||||
@ -250,22 +271,22 @@ void LoginPage::handleRequest(Poco::Net::HTTPServerRequest& request, Poco::Net::
|
||||
responseStream << "<div class=\"center-form-selectors\">\n";
|
||||
responseStream << "<form method=\"GET\" action=\"\">\n";
|
||||
responseStream << "\t<button id=\"flag-england\" name=\"lang\" value=\"en\" title=\"English\" type=\"submit\" ";
|
||||
#line 3 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\flags.cpsp"
|
||||
#line 3 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\flags.cpsp"
|
||||
if(lang != LANG_EN) { responseStream << "class=\"flag-btn\"";
|
||||
#line 3 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\flags.cpsp"
|
||||
#line 3 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\flags.cpsp"
|
||||
}
|
||||
else { responseStream << "class=\"flag-btn\" disabled";
|
||||
#line 4 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\flags.cpsp"
|
||||
#line 4 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\flags.cpsp"
|
||||
} responseStream << ">\n";
|
||||
responseStream << "\t <span class=\"flag flag-england\"></span>\n";
|
||||
responseStream << "\t</button>\n";
|
||||
responseStream << "\t<button id=\"flag-germany\" name=\"lang\" value=\"de\" title=\"Deutsch\" type=\"submit\" ";
|
||||
#line 7 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\flags.cpsp"
|
||||
#line 7 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\flags.cpsp"
|
||||
if(lang != LANG_DE) { responseStream << "class=\"flag-btn\"";
|
||||
#line 7 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\flags.cpsp"
|
||||
#line 7 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\flags.cpsp"
|
||||
}
|
||||
else { responseStream << "class=\"flag-btn\" disabled";
|
||||
#line 8 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\flags.cpsp"
|
||||
#line 8 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\flags.cpsp"
|
||||
} responseStream << ">\n";
|
||||
responseStream << "\t <span class=\"flag flag-germany\"></span>\n";
|
||||
responseStream << "\t</button>\n";
|
||||
@ -275,22 +296,22 @@ void LoginPage::handleRequest(Poco::Net::HTTPServerRequest& request, Poco::Net::
|
||||
responseStream << "\n";
|
||||
responseStream << " <div class=\"center-form-form\">\n";
|
||||
responseStream << "\t\t<form action=\"";
|
||||
#line 168 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\login.cpsp"
|
||||
#line 175 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\login.cpsp"
|
||||
responseStream << ( ServerConfig::g_serverPath );
|
||||
responseStream << "/\" method=\"POST\">\n";
|
||||
responseStream << "\t\t\t<input class=\"form-control\" type=\"text\" name=\"login-email\" placeholder=\"";
|
||||
#line 169 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\login.cpsp"
|
||||
#line 176 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\login.cpsp"
|
||||
responseStream << ( langCatalog->gettext("E-Mail") );
|
||||
responseStream << "\" value=\"";
|
||||
#line 169 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\login.cpsp"
|
||||
#line 176 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\login.cpsp"
|
||||
responseStream << ( presetEmail );
|
||||
responseStream << "\"/>\n";
|
||||
responseStream << "\t\t\t<input class=\"form-control\" type=\"password\" name=\"login-password\" placeholder=\"";
|
||||
#line 170 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\login.cpsp"
|
||||
#line 177 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\login.cpsp"
|
||||
responseStream << ( langCatalog->gettext("Password") );
|
||||
responseStream << "\" />\n";
|
||||
responseStream << "\t\t <button type=\"submit\" name=\"submit\" class=\"center-form-submit form-button\">";
|
||||
#line 171 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\login.cpsp"
|
||||
#line 178 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\login.cpsp"
|
||||
responseStream << ( langCatalog->gettext(" Login ") );
|
||||
responseStream << "</button>\n";
|
||||
responseStream << "\t\t</form>\n";
|
||||
@ -313,15 +334,22 @@ void LoginPage::handleRequest(Poco::Net::HTTPServerRequest& request, Poco::Net::
|
||||
responseStream << "\t </div>\n";
|
||||
responseStream << "\t\t<div class=\"reset-pwd-link\">\n";
|
||||
responseStream << "\t\t\t<a href=\"";
|
||||
#line 182 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\login.cpsp"
|
||||
#line 189 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\login.cpsp"
|
||||
responseStream << ( ServerConfig::g_serverPath );
|
||||
responseStream << "/resetPassword\">";
|
||||
#line 182 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\login.cpsp"
|
||||
#line 189 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\login.cpsp"
|
||||
responseStream << ( langCatalog->gettext("Passwort vergessen") );
|
||||
responseStream << "</a>\n";
|
||||
responseStream << "\t\t</div>\n";
|
||||
responseStream << "\t</div>\n";
|
||||
responseStream << "</div>\n";
|
||||
responseStream << "<p> </p>\n";
|
||||
responseStream << "<div class=\"container\">\n";
|
||||
responseStream << "\t<a href=\"https://docs.google.com/document/d/1jZp-DiiMPI9ZPNXmjsvOQ1BtnfDFfx8BX7CDmA8KKjY/edit?usp=sharing\" target=\"_blank\">Zum Whitepaper</a>\n";
|
||||
responseStream << "\t<br>\n";
|
||||
responseStream << "\t<br>\n";
|
||||
responseStream << "\t<a href=\"https://docs.google.com/document/d/1kcX1guOi6tDgnFHD9tf7fB_MneKTx-0nHJxzdN8ygNs/edit?usp=sharing\" target=\"_blank\">To the Whitepaper</a>\n";
|
||||
responseStream << "</div>\n";
|
||||
// begin include footer.cpsp
|
||||
responseStream << " <div class=\"center-bottom\">\n";
|
||||
responseStream << " <p>Copyright © Gradido 2020</p>\n";
|
||||
@ -329,14 +357,14 @@ void LoginPage::handleRequest(Poco::Net::HTTPServerRequest& request, Poco::Net::
|
||||
responseStream << " </div>\n";
|
||||
responseStream << " <div class=\"bottomleft\">\n";
|
||||
responseStream << " ";
|
||||
#line 6 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\footer.cpsp"
|
||||
#line 6 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\footer.cpsp"
|
||||
responseStream << ( mTimeProfiler.string() );
|
||||
responseStream << "\n";
|
||||
responseStream << " </div>\n";
|
||||
responseStream << " <div class=\"bottomright\">\n";
|
||||
responseStream << " <p>Login Server in Entwicklung</p>\n";
|
||||
responseStream << " <p>Alpha ";
|
||||
#line 10 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\footer.cpsp"
|
||||
#line 10 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\footer.cpsp"
|
||||
responseStream << ( ServerConfig::g_versionString );
|
||||
responseStream << "</p>\n";
|
||||
responseStream << " </div>\n";
|
||||
|
||||
@ -1,20 +1,20 @@
|
||||
#ifndef LoginPage_INCLUDED
|
||||
#define LoginPage_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Net/HTTPRequestHandler.h"
|
||||
|
||||
|
||||
#include "SessionHTTPRequestHandler.h"
|
||||
|
||||
|
||||
class LoginPage: public SessionHTTPRequestHandler
|
||||
{
|
||||
public:
|
||||
LoginPage(Session*);
|
||||
|
||||
void handleRequest(Poco::Net::HTTPServerRequest& request, Poco::Net::HTTPServerResponse& response);
|
||||
};
|
||||
|
||||
|
||||
#endif // LoginPage_INCLUDED
|
||||
#ifndef LoginPage_INCLUDED
|
||||
#define LoginPage_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Net/HTTPRequestHandler.h"
|
||||
|
||||
|
||||
#include "SessionHTTPRequestHandler.h"
|
||||
|
||||
|
||||
class LoginPage: public SessionHTTPRequestHandler
|
||||
{
|
||||
public:
|
||||
LoginPage(Session*);
|
||||
|
||||
void handleRequest(Poco::Net::HTTPServerRequest& request, Poco::Net::HTTPServerResponse& response);
|
||||
};
|
||||
|
||||
|
||||
#endif // LoginPage_INCLUDED
|
||||
|
||||
@ -5,15 +5,16 @@
|
||||
#include "Poco/DeflatingStream.h"
|
||||
|
||||
|
||||
#line 7 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\registerAdmin.cpsp"
|
||||
#line 7 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\registerAdmin.cpsp"
|
||||
|
||||
#include "../SingletonManager/SessionManager.h"
|
||||
#include "../controller/Group.h"
|
||||
#include "../lib/DataTypeConverter.h"
|
||||
|
||||
#include "Poco/Net/HTTPCookie.h"
|
||||
#include "../ServerConfig.h"
|
||||
|
||||
#line 1 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\header_old.cpsp"
|
||||
#line 1 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\header_old.cpsp"
|
||||
|
||||
#include "../ServerConfig.h"
|
||||
|
||||
@ -32,7 +33,7 @@ void RegisterAdminPage::handleRequest(Poco::Net::HTTPServerRequest& request, Poc
|
||||
if (_compressResponse) response.set("Content-Encoding", "gzip");
|
||||
|
||||
Poco::Net::HTMLForm form(request, request.stream());
|
||||
#line 15 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\registerAdmin.cpsp"
|
||||
#line 16 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\registerAdmin.cpsp"
|
||||
|
||||
const char* pageName = "Admin Registrieren";
|
||||
auto sm = SessionManager::getInstance();
|
||||
@ -76,12 +77,12 @@ void RegisterAdminPage::handleRequest(Poco::Net::HTTPServerRequest& request, Poc
|
||||
responseStream << "<meta charset=\"UTF-8\">\n";
|
||||
responseStream << "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n";
|
||||
responseStream << "<title>Gradido Login Server: ";
|
||||
#line 9 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\header_old.cpsp"
|
||||
#line 9 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\header_old.cpsp"
|
||||
responseStream << ( pageName );
|
||||
responseStream << "</title>\n";
|
||||
responseStream << "<!--<link rel=\"stylesheet\" type=\"text/css\" href=\"css/styles.min.css\">-->\n";
|
||||
responseStream << "<link rel=\"stylesheet\" type=\"text/css\" href=\"";
|
||||
#line 11 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\header_old.cpsp"
|
||||
#line 11 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\header_old.cpsp"
|
||||
responseStream << ( ServerConfig::g_php_serverPath );
|
||||
responseStream << "/css/styles.css\">\n";
|
||||
responseStream << "<style type=\"text/css\" >\n";
|
||||
@ -126,7 +127,7 @@ void RegisterAdminPage::handleRequest(Poco::Net::HTTPServerRequest& request, Poc
|
||||
responseStream << "<div class=\"versionstring dev-info\">\n";
|
||||
responseStream << "\t<p class=\"grd_small\">Login Server in Entwicklung</p>\n";
|
||||
responseStream << "\t<p class=\"grd_small\">Alpha ";
|
||||
#line 53 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\header_old.cpsp"
|
||||
#line 53 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\header_old.cpsp"
|
||||
responseStream << ( ServerConfig::g_versionString );
|
||||
responseStream << "</p>\n";
|
||||
responseStream << "</div>\n";
|
||||
@ -135,19 +136,23 @@ void RegisterAdminPage::handleRequest(Poco::Net::HTTPServerRequest& request, Poc
|
||||
responseStream << "<div class=\"grd_container\">\n";
|
||||
responseStream << "\t<h1>Einen neuen Account anlegen</h1>\n";
|
||||
responseStream << "\t";
|
||||
#line 49 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\registerAdmin.cpsp"
|
||||
#line 50 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\registerAdmin.cpsp"
|
||||
responseStream << ( getErrorsHtml() );
|
||||
responseStream << "\n";
|
||||
responseStream << "\t";
|
||||
#line 50 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\registerAdmin.cpsp"
|
||||
#line 51 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\registerAdmin.cpsp"
|
||||
if(!form.empty() && userReturned) { responseStream << "\n";
|
||||
responseStream << "\t\t<div class=\"grd_text-max-width\">\n";
|
||||
responseStream << "\t\t\t<div class=\"grd_text\">\n";
|
||||
responseStream << "\t\t\t\tDie Anmeldung wird verarbeitet und es wird dem Benutzer eine Aktivierungs-E-Mail zugeschickt. \n";
|
||||
responseStream << "\t\t\t</div>\n";
|
||||
responseStream << "\t\t</div>\n";
|
||||
responseStream << "\t\t<a href=\"";
|
||||
#line 57 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\registerAdmin.cpsp"
|
||||
responseStream << ( ServerConfig::g_php_serverHost );
|
||||
responseStream << "\">Zurück</a>\n";
|
||||
responseStream << "\t";
|
||||
#line 56 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\registerAdmin.cpsp"
|
||||
#line 58 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\registerAdmin.cpsp"
|
||||
} else { responseStream << "\n";
|
||||
responseStream << "\t<form method=\"POST\">\n";
|
||||
responseStream << "\t\t\n";
|
||||
@ -157,41 +162,41 @@ void RegisterAdminPage::handleRequest(Poco::Net::HTTPServerRequest& request, Poc
|
||||
responseStream << "\t\t\t<p class=\"grd_small\">\n";
|
||||
responseStream << "\t\t\t\t<label for=\"register-first-name\">Vorname</label>\n";
|
||||
responseStream << "\t\t\t\t<input id=\"register-first-name\" type=\"text\" name=\"register-first-name\" value=\"";
|
||||
#line 64 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\registerAdmin.cpsp"
|
||||
#line 66 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\registerAdmin.cpsp"
|
||||
responseStream << ( !form.empty() ? form.get("register-first-name") : "" );
|
||||
responseStream << "\"/>\n";
|
||||
responseStream << "\t\t\t</p>\n";
|
||||
responseStream << "\t\t\t<p class=\"grd_small\">\n";
|
||||
responseStream << "\t\t\t\t<label for=\"register-last-name\">Nachname</label>\n";
|
||||
responseStream << "\t\t\t\t<input id=\"register-last-name\" type=\"text\" name=\"register-last-name\" value=\"";
|
||||
#line 68 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\registerAdmin.cpsp"
|
||||
#line 70 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\registerAdmin.cpsp"
|
||||
responseStream << ( !form.empty() ? form.get("register-last-name") : "" );
|
||||
responseStream << "\"/>\n";
|
||||
responseStream << "\t\t\t</p>\n";
|
||||
responseStream << "\t\t\t<p class=\"grd_small\">\n";
|
||||
responseStream << "\t\t\t\t<label for=\"register-email\">E-Mail</label>\n";
|
||||
responseStream << "\t\t\t\t<input id=\"register-email\" type=\"email\" name=\"register-email\" value=\"";
|
||||
#line 72 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\registerAdmin.cpsp"
|
||||
#line 74 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\registerAdmin.cpsp"
|
||||
responseStream << ( !form.empty() ? form.get("register-email") : "" );
|
||||
responseStream << "\"/>\n";
|
||||
responseStream << "\t\t\t</p>\n";
|
||||
responseStream << "\t\t\t<select class=\"form-control\" name=\"register-group\">\n";
|
||||
responseStream << "\t\t\t\t";
|
||||
#line 75 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\registerAdmin.cpsp"
|
||||
#line 77 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\registerAdmin.cpsp"
|
||||
for(auto it = groups.begin(); it != groups.end(); it++) {
|
||||
auto group_model = (*it)->getModel(); responseStream << "\n";
|
||||
responseStream << "\t\t\t\t\t<option title=\"";
|
||||
#line 77 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\registerAdmin.cpsp"
|
||||
#line 79 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\registerAdmin.cpsp"
|
||||
responseStream << ( group_model->getDescription() );
|
||||
responseStream << "\" value=\"";
|
||||
#line 77 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\registerAdmin.cpsp"
|
||||
#line 79 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\registerAdmin.cpsp"
|
||||
responseStream << ( group_model->getID() );
|
||||
responseStream << "\">";
|
||||
#line 77 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\registerAdmin.cpsp"
|
||||
#line 79 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\registerAdmin.cpsp"
|
||||
responseStream << ( group_model->getName() );
|
||||
responseStream << "</option>\n";
|
||||
responseStream << "\t\t\t\t";
|
||||
#line 78 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\registerAdmin.cpsp"
|
||||
#line 80 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\registerAdmin.cpsp"
|
||||
} responseStream << "\n";
|
||||
responseStream << "\t\t\t</select>\n";
|
||||
responseStream << "\t\t</fieldset>\n";
|
||||
@ -199,7 +204,7 @@ void RegisterAdminPage::handleRequest(Poco::Net::HTTPServerRequest& request, Poc
|
||||
responseStream << "\t\t\n";
|
||||
responseStream << "\t</form>\n";
|
||||
responseStream << "\t";
|
||||
#line 84 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\registerAdmin.cpsp"
|
||||
#line 86 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\registerAdmin.cpsp"
|
||||
} responseStream << "\n";
|
||||
responseStream << "</div>\n";
|
||||
// begin include footer.cpsp
|
||||
@ -209,14 +214,14 @@ void RegisterAdminPage::handleRequest(Poco::Net::HTTPServerRequest& request, Poc
|
||||
responseStream << " </div>\n";
|
||||
responseStream << " <div class=\"bottomleft\">\n";
|
||||
responseStream << " ";
|
||||
#line 6 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\footer.cpsp"
|
||||
#line 6 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\footer.cpsp"
|
||||
responseStream << ( mTimeProfiler.string() );
|
||||
responseStream << "\n";
|
||||
responseStream << " </div>\n";
|
||||
responseStream << " <div class=\"bottomright\">\n";
|
||||
responseStream << " <p>Login Server in Entwicklung</p>\n";
|
||||
responseStream << " <p>Alpha ";
|
||||
#line 10 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\footer.cpsp"
|
||||
#line 10 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\footer.cpsp"
|
||||
responseStream << ( ServerConfig::g_versionString );
|
||||
responseStream << "</p>\n";
|
||||
responseStream << " </div>\n";
|
||||
|
||||
@ -5,11 +5,11 @@
|
||||
#include "Poco/DeflatingStream.h"
|
||||
|
||||
|
||||
#line 7 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\translatePassphrase.cpsp"
|
||||
#line 7 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\translatePassphrase.cpsp"
|
||||
|
||||
#include "../Crypto/KeyPairEd25519.h"
|
||||
#include "../ServerConfig.h"
|
||||
#line 1 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\header.cpsp"
|
||||
#line 1 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\header.cpsp"
|
||||
|
||||
#include "../ServerConfig.h"
|
||||
|
||||
@ -28,7 +28,7 @@ void TranslatePassphrase::handleRequest(Poco::Net::HTTPServerRequest& request, P
|
||||
if (_compressResponse) response.set("Content-Encoding", "gzip");
|
||||
|
||||
Poco::Net::HTMLForm form(request, request.stream());
|
||||
#line 11 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\translatePassphrase.cpsp"
|
||||
#line 11 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\translatePassphrase.cpsp"
|
||||
|
||||
chooseLanguage(request);
|
||||
// variable needed for flags
|
||||
@ -40,9 +40,9 @@ void TranslatePassphrase::handleRequest(Poco::Net::HTTPServerRequest& request, P
|
||||
std::string inputPassphrase;
|
||||
|
||||
Mnemonic* wordSource = &ServerConfig::g_Mnemonic_WordLists[ServerConfig::MNEMONIC_BIP0039_SORTED_ORDER];
|
||||
Mnemonic* targetSource = &ServerConfig::g_Mnemonic_WordLists[ServerConfig::MNEMONIC_GRADIDO_BOOK_GERMAN_RANDOM_ORDER];
|
||||
Mnemonic* targetSource = &ServerConfig::g_Mnemonic_WordLists[ServerConfig::MNEMONIC_GRADIDO_BOOK_GERMAN_RANDOM_ORDER_FIXED_CASES];
|
||||
if(lang == LANG_DE) {
|
||||
wordSource = &ServerConfig::g_Mnemonic_WordLists[ServerConfig::MNEMONIC_GRADIDO_BOOK_GERMAN_RANDOM_ORDER];
|
||||
wordSource = &ServerConfig::g_Mnemonic_WordLists[ServerConfig::MNEMONIC_GRADIDO_BOOK_GERMAN_RANDOM_ORDER_FIXED_CASES];
|
||||
targetSource = &ServerConfig::g_Mnemonic_WordLists[ServerConfig::MNEMONIC_BIP0039_SORTED_ORDER];
|
||||
}
|
||||
|
||||
@ -67,7 +67,7 @@ void TranslatePassphrase::handleRequest(Poco::Net::HTTPServerRequest& request, P
|
||||
), false);
|
||||
} else {
|
||||
if(wordSource == &ServerConfig::g_Mnemonic_WordLists[ServerConfig::MNEMONIC_BIP0039_SORTED_ORDER]) {
|
||||
targetSource = &ServerConfig::g_Mnemonic_WordLists[ServerConfig::MNEMONIC_GRADIDO_BOOK_GERMAN_RANDOM_ORDER];
|
||||
targetSource = &ServerConfig::g_Mnemonic_WordLists[ServerConfig::MNEMONIC_GRADIDO_BOOK_GERMAN_RANDOM_ORDER_FIXED_CASES];
|
||||
} else {
|
||||
targetSource = &ServerConfig::g_Mnemonic_WordLists[ServerConfig::MNEMONIC_BIP0039_SORTED_ORDER];
|
||||
}
|
||||
@ -77,7 +77,7 @@ void TranslatePassphrase::handleRequest(Poco::Net::HTTPServerRequest& request, P
|
||||
|
||||
|
||||
}
|
||||
#line 3 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\header.cpsp"
|
||||
#line 3 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\header.cpsp"
|
||||
|
||||
bool withMaterialIcons = false;
|
||||
std::ostream& _responseStream = response.send();
|
||||
@ -93,20 +93,20 @@ void TranslatePassphrase::handleRequest(Poco::Net::HTTPServerRequest& request, P
|
||||
responseStream << "<meta charset=\"UTF-8\">\n";
|
||||
responseStream << "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1, shrink-to-fit=no\">\n";
|
||||
responseStream << "<title>Gradido Login Server: ";
|
||||
#line 11 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\header.cpsp"
|
||||
#line 11 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\header.cpsp"
|
||||
responseStream << ( pageName );
|
||||
responseStream << "</title>\n";
|
||||
responseStream << "<link rel=\"stylesheet\" type=\"text/css\" href=\"";
|
||||
#line 12 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\header.cpsp"
|
||||
#line 12 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\header.cpsp"
|
||||
responseStream << ( ServerConfig::g_php_serverPath );
|
||||
responseStream << "css/main.css\">\n";
|
||||
#line 13 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\header.cpsp"
|
||||
#line 13 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\header.cpsp"
|
||||
if(withMaterialIcons) { responseStream << "\n";
|
||||
responseStream << "<link rel=\"stylesheet\" type=\"text/css\" href=\"";
|
||||
#line 14 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\header.cpsp"
|
||||
#line 14 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\header.cpsp"
|
||||
responseStream << ( ServerConfig::g_php_serverPath );
|
||||
responseStream << "css/materialdesignicons.min.css\">\n";
|
||||
#line 15 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\header.cpsp"
|
||||
#line 15 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\header.cpsp"
|
||||
} responseStream << "\n";
|
||||
responseStream << "</head>\n";
|
||||
responseStream << "<body>\n";
|
||||
@ -114,20 +114,20 @@ void TranslatePassphrase::handleRequest(Poco::Net::HTTPServerRequest& request, P
|
||||
responseStream << " <div class=\"center-form-single\">\n";
|
||||
responseStream << " <div class=\"center-form-header\">\n";
|
||||
responseStream << " <a href=\"";
|
||||
#line 21 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\header.cpsp"
|
||||
#line 21 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\header.cpsp"
|
||||
responseStream << ( ServerConfig::g_php_serverPath );
|
||||
responseStream << "\" class=\"center-logo\">\n";
|
||||
responseStream << " <picture>\n";
|
||||
responseStream << " <source srcset=\"";
|
||||
#line 23 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\header.cpsp"
|
||||
#line 23 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\header.cpsp"
|
||||
responseStream << ( ServerConfig::g_php_serverPath );
|
||||
responseStream << "img/logo_schrift.webp\" type=\"image/webp\">\n";
|
||||
responseStream << " <source srcset=\"";
|
||||
#line 24 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\header.cpsp"
|
||||
#line 24 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\header.cpsp"
|
||||
responseStream << ( ServerConfig::g_php_serverPath );
|
||||
responseStream << "img/logo_schrift.png\" type=\"image/png\">\n";
|
||||
responseStream << " <img src=\"";
|
||||
#line 25 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\header.cpsp"
|
||||
#line 25 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\header.cpsp"
|
||||
responseStream << ( ServerConfig::g_php_serverPath );
|
||||
responseStream << "img/logo_schrift.png\" alt=\"logo\" />\n";
|
||||
responseStream << " </picture>\n";
|
||||
@ -139,20 +139,20 @@ void TranslatePassphrase::handleRequest(Poco::Net::HTTPServerRequest& request, P
|
||||
responseStream << " <div class=\"row\">\n";
|
||||
responseStream << " <div class=\"col-12 logo-section\">\n";
|
||||
responseStream << " <a href=\"";
|
||||
#line 5 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\login_header.cpsp"
|
||||
#line 5 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\login_header.cpsp"
|
||||
responseStream << ( ServerConfig::g_php_serverPath );
|
||||
responseStream << "\" class=\"logo\">\n";
|
||||
responseStream << " <picture>\n";
|
||||
responseStream << "\t\t\t\t<source srcset=\"";
|
||||
#line 7 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\login_header.cpsp"
|
||||
#line 7 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\login_header.cpsp"
|
||||
responseStream << ( ServerConfig::g_php_serverPath );
|
||||
responseStream << "img/logo_schrift.webp\" type=\"image/webp\">\n";
|
||||
responseStream << "\t\t\t\t<source srcset=\"";
|
||||
#line 8 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\login_header.cpsp"
|
||||
#line 8 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\login_header.cpsp"
|
||||
responseStream << ( ServerConfig::g_php_serverPath );
|
||||
responseStream << "img/logo_schrift.png\" type=\"image/png\"> \n";
|
||||
responseStream << "\t\t\t\t<img src=\"";
|
||||
#line 9 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\login_header.cpsp"
|
||||
#line 9 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\login_header.cpsp"
|
||||
responseStream << ( ServerConfig::g_php_serverPath );
|
||||
responseStream << "img/logo_schrift.png\" alt=\"logo\" />\n";
|
||||
responseStream << "\t\t\t</picture>\n";
|
||||
@ -164,7 +164,7 @@ void TranslatePassphrase::handleRequest(Poco::Net::HTTPServerRequest& request, P
|
||||
responseStream << " <div class=\"grid\">\n";
|
||||
responseStream << " <div class=\"center-ul-container\">\n";
|
||||
responseStream << " ";
|
||||
#line 18 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\login_header.cpsp"
|
||||
#line 18 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\login_header.cpsp"
|
||||
responseStream << ( getErrorsHtml() );
|
||||
responseStream << "\n";
|
||||
responseStream << " </div>\n";
|
||||
@ -174,22 +174,22 @@ void TranslatePassphrase::handleRequest(Poco::Net::HTTPServerRequest& request, P
|
||||
responseStream << "<div class=\"center-form-selectors\">\n";
|
||||
responseStream << "<form method=\"GET\" action=\"\">\n";
|
||||
responseStream << "\t<button id=\"flag-england\" name=\"lang\" value=\"en\" title=\"English\" type=\"submit\" ";
|
||||
#line 3 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\flags.cpsp"
|
||||
#line 3 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\flags.cpsp"
|
||||
if(lang != LANG_EN) { responseStream << "class=\"flag-btn\"";
|
||||
#line 3 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\flags.cpsp"
|
||||
#line 3 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\flags.cpsp"
|
||||
}
|
||||
else { responseStream << "class=\"flag-btn\" disabled";
|
||||
#line 4 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\flags.cpsp"
|
||||
#line 4 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\flags.cpsp"
|
||||
} responseStream << ">\n";
|
||||
responseStream << "\t <span class=\"flag flag-england\"></span>\n";
|
||||
responseStream << "\t</button>\n";
|
||||
responseStream << "\t<button id=\"flag-germany\" name=\"lang\" value=\"de\" title=\"Deutsch\" type=\"submit\" ";
|
||||
#line 7 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\flags.cpsp"
|
||||
#line 7 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\flags.cpsp"
|
||||
if(lang != LANG_DE) { responseStream << "class=\"flag-btn\"";
|
||||
#line 7 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\flags.cpsp"
|
||||
#line 7 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\flags.cpsp"
|
||||
}
|
||||
else { responseStream << "class=\"flag-btn\" disabled";
|
||||
#line 8 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\flags.cpsp"
|
||||
#line 8 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\flags.cpsp"
|
||||
} responseStream << ">\n";
|
||||
responseStream << "\t <span class=\"flag flag-germany\"></span>\n";
|
||||
responseStream << "\t</button>\n";
|
||||
@ -199,7 +199,7 @@ void TranslatePassphrase::handleRequest(Poco::Net::HTTPServerRequest& request, P
|
||||
responseStream << "\n";
|
||||
responseStream << "<div class=\"row mb-3\" style=\"margin-top:70px;\">\n";
|
||||
responseStream << "\t<h2 class=\"mx-auto\">";
|
||||
#line 61 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\translatePassphrase.cpsp"
|
||||
#line 61 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\translatePassphrase.cpsp"
|
||||
responseStream << ( gettext("Passphrase umwandeln") );
|
||||
responseStream << "</h2>\n";
|
||||
responseStream << "</div>\n";
|
||||
@ -210,57 +210,57 @@ void TranslatePassphrase::handleRequest(Poco::Net::HTTPServerRequest& request, P
|
||||
responseStream << "\t <div class=\"col-md-12 col-lg-12 \">\n";
|
||||
responseStream << "\t\t<div class=\"alert alert-orange\">\n";
|
||||
responseStream << "\t\t <h5 class=\"alert-heading\">";
|
||||
#line 69 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\translatePassphrase.cpsp"
|
||||
#line 69 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\translatePassphrase.cpsp"
|
||||
responseStream << ( gettext("Was zu tun ist:") );
|
||||
responseStream << "</h5>\n";
|
||||
responseStream << "\t\t <p>";
|
||||
#line 70 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\translatePassphrase.cpsp"
|
||||
#line 70 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\translatePassphrase.cpsp"
|
||||
responseStream << ( gettext("Kopiere/schreibe deine Passphrase in die Textbox und du bekommst sie in die jeweils andere Sprache umgewandelt.") );
|
||||
responseStream << "</p>\n";
|
||||
responseStream << "\t\t <p>";
|
||||
#line 71 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\translatePassphrase.cpsp"
|
||||
#line 71 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\translatePassphrase.cpsp"
|
||||
responseStream << ( gettext("Du kannst mit beiden Varianten dein Konto wiederherstellen oder dein Passwort ändern.") );
|
||||
responseStream << "</p>\n";
|
||||
responseStream << "\t\t</div>\n";
|
||||
responseStream << "\t </div>\n";
|
||||
responseStream << "\t <div class=\"col-lg-12 col-md-12 mb-5\">\n";
|
||||
responseStream << "\t\t<form action=\"";
|
||||
#line 75 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\translatePassphrase.cpsp"
|
||||
#line 75 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\translatePassphrase.cpsp"
|
||||
responseStream << ( uri_start );
|
||||
responseStream << "/transform_passphrase\">\n";
|
||||
responseStream << "\t\t <div class=\"form-group row-showcase_row_area\">\n";
|
||||
responseStream << "\t\t\t<textarea name=\"inputPassphrase\" cols=\"10\" rows=\"5\" id=\"inputPassphrase\" class=\"form-control\" placeholder=\"";
|
||||
#line 77 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\translatePassphrase.cpsp"
|
||||
responseStream << "\t\t\t<textarea name=\"inputPassphrase\" cols=\"20\" rows=\"10\" id=\"inputPassphrase\" class=\"form-control\" placeholder=\"";
|
||||
#line 77 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\translatePassphrase.cpsp"
|
||||
responseStream << ( gettext("deine Passphrase") );
|
||||
responseStream << "\">";
|
||||
#line 77 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\translatePassphrase.cpsp"
|
||||
#line 77 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\translatePassphrase.cpsp"
|
||||
responseStream << ( inputPassphrase );
|
||||
responseStream << "</textarea>\n";
|
||||
responseStream << "\t\t </div>\n";
|
||||
responseStream << "\t\t <input name=\"btnTransform\" type=\"submit\" value=\"Umwandeln\" class=\"btn btn btn-orange\">\n";
|
||||
responseStream << "\t\t ";
|
||||
#line 80 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\translatePassphrase.cpsp"
|
||||
#line 80 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\translatePassphrase.cpsp"
|
||||
if(model::table::ROLE_ADMIN == role) { responseStream << "\n";
|
||||
responseStream << "\t\t\t<input name=\"btnGenerate\" type=\"submit\" value=\"Neue generieren\" class=\"btn btn-secondary\">\n";
|
||||
responseStream << "\t\t ";
|
||||
#line 82 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\translatePassphrase.cpsp"
|
||||
#line 82 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\translatePassphrase.cpsp"
|
||||
} responseStream << "\n";
|
||||
responseStream << "\t\t</form>\n";
|
||||
responseStream << "\t </div>\n";
|
||||
responseStream << "\t ";
|
||||
#line 85 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\translatePassphrase.cpsp"
|
||||
#line 85 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\translatePassphrase.cpsp"
|
||||
if(passphrase != "") { responseStream << "\n";
|
||||
responseStream << "\t\t<div class=\"col-lg-12 col-md-12\">\n";
|
||||
responseStream << "\t\t\t<div class=\"alert alert-success\">\n";
|
||||
responseStream << "\t\t\t\t<h5 class=\"alert-heading\">Umgewandelte Passphrase: </h5>\n";
|
||||
responseStream << "\t\t\t\t<p>";
|
||||
#line 89 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\translatePassphrase.cpsp"
|
||||
#line 89 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\translatePassphrase.cpsp"
|
||||
responseStream << ( passphrase );
|
||||
responseStream << "</p>\n";
|
||||
responseStream << "\t\t\t</div>\n";
|
||||
responseStream << "\t\t</div>\n";
|
||||
responseStream << "\t ";
|
||||
#line 92 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\translatePassphrase.cpsp"
|
||||
#line 92 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\translatePassphrase.cpsp"
|
||||
} responseStream << "\n";
|
||||
responseStream << "\t </div>\n";
|
||||
responseStream << "\t</div>\n";
|
||||
@ -289,7 +289,7 @@ void TranslatePassphrase::handleRequest(Poco::Net::HTTPServerRequest& request, P
|
||||
responseStream << " </div>\n";
|
||||
responseStream << " <div class=\"grd-time-used dev-info\">\n";
|
||||
responseStream << " ";
|
||||
#line 23 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\footer_ripple.cpsp"
|
||||
#line 23 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\footer_ripple.cpsp"
|
||||
responseStream << ( mTimeProfiler.string() );
|
||||
responseStream << "\n";
|
||||
responseStream << " </div>\n";
|
||||
@ -305,7 +305,7 @@ void TranslatePassphrase::handleRequest(Poco::Net::HTTPServerRequest& request, P
|
||||
responseStream << " <!-- build:js -->\n";
|
||||
responseStream << " <!--<script src=\"../../../assets/js/template.js\"></script>-->\n";
|
||||
responseStream << " <script src=\"";
|
||||
#line 36 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\footer_ripple.cpsp"
|
||||
#line 36 "D:\\code\\gradido\\gradido_login_server_grpc\\src\\cpsp\\footer_ripple.cpsp"
|
||||
responseStream << ( ServerConfig::g_php_serverPath );
|
||||
responseStream << "/js/basic.js\"></script>\n";
|
||||
responseStream << " <!--<script src=\"../../../assets/js/dashboard.js\"></script>-->\n";
|
||||
|
||||
@ -5,15 +5,21 @@
|
||||
#include "../controller/EmailVerificationCode.h"
|
||||
|
||||
#include "../SingletonManager/EmailManager.h"
|
||||
#include "../SingletonManager/SessionManager.h"
|
||||
|
||||
#include "../tasks/AuthenticatedEncryptionCreateKeyTask.h"
|
||||
|
||||
Poco::JSON::Object* JsonCreateUser::handle(Poco::Dynamic::Var params)
|
||||
{
|
||||
std::string email;
|
||||
std::string first_name;
|
||||
std::string last_name;
|
||||
std::string password;
|
||||
bool login_after_register = false;
|
||||
int emailType;
|
||||
int group_id;
|
||||
auto em = EmailManager::getInstance();
|
||||
auto sm = SessionManager::getInstance();
|
||||
|
||||
// if is json object
|
||||
if (params.type() == typeid(Poco::JSON::Object::Ptr)) {
|
||||
@ -29,6 +35,12 @@ Poco::JSON::Object* JsonCreateUser::handle(Poco::Dynamic::Var params)
|
||||
paramJsonObject->get("last_name").convert(last_name);
|
||||
paramJsonObject->get("emailType").convert(emailType);
|
||||
paramJsonObject->get("group_id").convert(group_id);
|
||||
if ((ServerConfig::g_AllowUnsecureFlags & ServerConfig::UNSECURE_PASSWORD_REQUESTS)) {
|
||||
paramJsonObject->get("password").convert(password);
|
||||
}
|
||||
if (!paramJsonObject->isNull("login_after_register")) {
|
||||
paramJsonObject->get("login_after_register").convert(login_after_register);
|
||||
}
|
||||
}
|
||||
catch (Poco::Exception& ex) {
|
||||
return stateError("json exception", ex.displayText());
|
||||
@ -40,19 +52,46 @@ Poco::JSON::Object* JsonCreateUser::handle(Poco::Dynamic::Var params)
|
||||
|
||||
auto user = controller::User::create();
|
||||
if (user->load(email) > 0) {
|
||||
// return customStateError("exist", "user already exist");
|
||||
Poco::JSON::Object* result = new Poco::JSON::Object;
|
||||
result->set("state", "exist");
|
||||
result->set("msg", "user already exist");
|
||||
return result;
|
||||
}
|
||||
|
||||
if (password.size()) {
|
||||
ErrorList errors;
|
||||
if (!sm->checkPwdValidation(password, &errors)) {
|
||||
Poco::JSON::Object* result = new Poco::JSON::Object;
|
||||
result->set("state", "error");
|
||||
result->set("msg", errors.getLastError()->getString(false));
|
||||
if (errors.errorCount()) {
|
||||
result->set("details", errors.getLastError()->getString(false));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
// create user
|
||||
user = controller::User::create(email, first_name, last_name, group_id);
|
||||
auto userModel = user->getModel();
|
||||
Session* session = nullptr;
|
||||
|
||||
if (!userModel->insertIntoDB(true)) {
|
||||
userModel->sendErrorsAsEmail();
|
||||
return stateError("insert user failed");
|
||||
}
|
||||
if (password.size()) {
|
||||
session = sm->getNewSession();
|
||||
session->setUser(user);
|
||||
session->generateKeys(true, true);
|
||||
session->setClientIp(mClientIP);
|
||||
|
||||
// calculate encryption key, could need some time, will save encrypted privkey to db
|
||||
UniLib::controller::TaskPtr create_authenticated_encrypten_key = new AuthenticatedEncryptionCreateKeyTask(user, password);
|
||||
create_authenticated_encrypten_key->scheduleTask(create_authenticated_encrypten_key);
|
||||
}
|
||||
|
||||
auto emailOptIn = controller::EmailVerificationCode::create(userModel->getID(), model::table::EMAIL_OPT_IN_REGISTER);
|
||||
auto emailOptInModel = emailOptIn->getModel();
|
||||
if (!emailOptInModel->insertIntoDB(false)) {
|
||||
@ -62,6 +101,12 @@ Poco::JSON::Object* JsonCreateUser::handle(Poco::Dynamic::Var params)
|
||||
|
||||
em->addEmail(new model::Email(emailOptIn, user, model::Email::convertTypeFromInt(emailType)));
|
||||
|
||||
if (login_after_register && session) {
|
||||
Poco::JSON::Object* result = stateSuccess();
|
||||
|
||||
result->set("session_id", session->getHandle());
|
||||
return result;
|
||||
}
|
||||
|
||||
return stateSuccess();
|
||||
|
||||
}
|
||||
@ -6,9 +6,11 @@
|
||||
class JsonCreateUser : public JsonRequestHandler
|
||||
{
|
||||
public:
|
||||
JsonCreateUser(Poco::Net::IPAddress ip) : mClientIP(ip) {}
|
||||
Poco::JSON::Object* handle(Poco::Dynamic::Var params);
|
||||
|
||||
protected:
|
||||
Poco::Net::IPAddress mClientIP;
|
||||
|
||||
|
||||
};
|
||||
|
||||
@ -1,113 +1,123 @@
|
||||
#include "JsonGetUserInfos.h"
|
||||
|
||||
#include "../lib/DataTypeConverter.h"
|
||||
#include "../SingletonManager/SessionManager.h"
|
||||
#include "../controller/User.h"
|
||||
#include "../controller/EmailVerificationCode.h"
|
||||
|
||||
#include "../ServerConfig.h"
|
||||
|
||||
Poco::JSON::Object* JsonGetUserInfos::handle(Poco::Dynamic::Var params)
|
||||
{
|
||||
/*
|
||||
'session_id' => $session_id,
|
||||
'email' => $email,
|
||||
'ask' => ['EmailOptIn.Register']
|
||||
*/
|
||||
// incoming
|
||||
int session_id = 0;
|
||||
std::string email;
|
||||
Poco::JSON::Array::Ptr askArray;
|
||||
|
||||
auto sm = SessionManager::getInstance();
|
||||
|
||||
// if is json object
|
||||
if (params.type() == typeid(Poco::JSON::Object::Ptr)) {
|
||||
Poco::JSON::Object::Ptr paramJsonObject = params.extract<Poco::JSON::Object::Ptr>();
|
||||
/// Throws a RangeException if the value does not fit
|
||||
/// into the result variable.
|
||||
/// Throws a NotImplementedException if conversion is
|
||||
/// not available for the given type.
|
||||
/// Throws InvalidAccessException if Var is empty.
|
||||
try {
|
||||
paramJsonObject->get("email").convert(email);
|
||||
paramJsonObject->get("session_id").convert(session_id);
|
||||
askArray = paramJsonObject->getArray("ask");
|
||||
}
|
||||
catch (Poco::Exception& ex) {
|
||||
return stateError("json exception", ex.displayText());
|
||||
}
|
||||
}
|
||||
else {
|
||||
return stateError("parameter format unknown");
|
||||
}
|
||||
|
||||
if (!session_id) {
|
||||
return stateError("session_id invalid");
|
||||
}
|
||||
if (askArray.isNull()) {
|
||||
return stateError("ask is zero or not an array");
|
||||
}
|
||||
|
||||
auto session = sm->getSession(session_id);
|
||||
if (!session) {
|
||||
return customStateError("not found", "session not found");
|
||||
}
|
||||
|
||||
auto user = controller::User::create();
|
||||
if (1 != user->load(email)) {
|
||||
return customStateError("not found", "user not found");
|
||||
}
|
||||
auto userModel = user->getModel();
|
||||
|
||||
|
||||
Poco::JSON::Object* result = new Poco::JSON::Object;
|
||||
result->set("state", "success");
|
||||
Poco::JSON::Array jsonErrorsArray;
|
||||
Poco::JSON::Object jsonUser;
|
||||
Poco::JSON::Object jsonServer;
|
||||
|
||||
for (auto it = askArray->begin(); it != askArray->end(); it++) {
|
||||
auto parameter = *it;
|
||||
std::string parameterString;
|
||||
try {
|
||||
parameter.convert(parameterString);
|
||||
if (parameterString == "EmailVerificationCode.Register") {
|
||||
try {
|
||||
auto emailVerificationCode = controller::EmailVerificationCode::load(
|
||||
userModel->getID(), model::table::EMAIL_OPT_IN_REGISTER
|
||||
);
|
||||
if (!emailVerificationCode) {
|
||||
emailVerificationCode = controller::EmailVerificationCode::create(userModel->getID(), model::table::EMAIL_OPT_IN_REGISTER);
|
||||
UniLib::controller::TaskPtr insert = new model::table::ModelInsertTask(emailVerificationCode->getModel(), false);
|
||||
insert->scheduleTask(insert);
|
||||
}
|
||||
jsonUser.set("EmailVerificationCode.Register", std::to_string(emailVerificationCode->getModel()->getCode()));
|
||||
}
|
||||
catch (Poco::Exception& ex) {
|
||||
printf("exception: %s\n", ex.displayText().data());
|
||||
}
|
||||
}
|
||||
else if (parameterString == "loginServer.path") {
|
||||
jsonServer.set("loginServer.path", ServerConfig::g_serverPath);
|
||||
}
|
||||
else if (parameterString == "user.pubkeyhex") {
|
||||
jsonUser.set("pubkeyhex", userModel->getPublicKeyHex());
|
||||
}
|
||||
else if (parameterString == "user.first_name") {
|
||||
jsonUser.set("first_name", userModel->getFirstName());
|
||||
}
|
||||
else if (parameterString == "user.last_name") {
|
||||
jsonUser.set("last_name", userModel->getLastName());
|
||||
}
|
||||
}
|
||||
catch (Poco::Exception& ex) {
|
||||
jsonErrorsArray.add("ask parameter invalid");
|
||||
}
|
||||
}
|
||||
result->set("errors", jsonErrorsArray);
|
||||
result->set("userData", jsonUser);
|
||||
result->set("server", jsonServer);
|
||||
return result;
|
||||
|
||||
#include "JsonGetUserInfos.h"
|
||||
|
||||
#include "../lib/DataTypeConverter.h"
|
||||
#include "../SingletonManager/SessionManager.h"
|
||||
#include "../controller/User.h"
|
||||
#include "../controller/EmailVerificationCode.h"
|
||||
|
||||
#include "../ServerConfig.h"
|
||||
|
||||
Poco::JSON::Object* JsonGetUserInfos::handle(Poco::Dynamic::Var params)
|
||||
{
|
||||
/*
|
||||
'session_id' => $session_id,
|
||||
'email' => $email,
|
||||
'ask' => ['EmailOptIn.Register']
|
||||
*/
|
||||
// incoming
|
||||
int session_id = 0;
|
||||
std::string email;
|
||||
Poco::JSON::Array::Ptr askArray;
|
||||
|
||||
auto sm = SessionManager::getInstance();
|
||||
|
||||
// if is json object
|
||||
if (params.type() == typeid(Poco::JSON::Object::Ptr)) {
|
||||
Poco::JSON::Object::Ptr paramJsonObject = params.extract<Poco::JSON::Object::Ptr>();
|
||||
/// Throws a RangeException if the value does not fit
|
||||
/// into the result variable.
|
||||
/// Throws a NotImplementedException if conversion is
|
||||
/// not available for the given type.
|
||||
/// Throws InvalidAccessException if Var is empty.
|
||||
try {
|
||||
paramJsonObject->get("email").convert(email);
|
||||
paramJsonObject->get("session_id").convert(session_id);
|
||||
askArray = paramJsonObject->getArray("ask");
|
||||
}
|
||||
catch (Poco::Exception& ex) {
|
||||
return stateError("json exception", ex.displayText());
|
||||
}
|
||||
}
|
||||
else {
|
||||
return stateError("parameter format unknown");
|
||||
}
|
||||
|
||||
if (!session_id) {
|
||||
return stateError("session_id invalid");
|
||||
}
|
||||
if (askArray.isNull()) {
|
||||
return stateError("ask is zero or not an array");
|
||||
}
|
||||
|
||||
auto session = sm->getSession(session_id);
|
||||
if (!session) {
|
||||
return customStateError("not found", "session not found");
|
||||
}
|
||||
|
||||
auto user = controller::User::create();
|
||||
if (1 != user->load(email)) {
|
||||
return customStateError("not found", "user not found");
|
||||
}
|
||||
auto userModel = user->getModel();
|
||||
|
||||
|
||||
Poco::JSON::Object* result = new Poco::JSON::Object;
|
||||
result->set("state", "success");
|
||||
Poco::JSON::Array jsonErrorsArray;
|
||||
Poco::JSON::Object jsonUser;
|
||||
Poco::JSON::Object jsonServer;
|
||||
|
||||
for (auto it = askArray->begin(); it != askArray->end(); it++) {
|
||||
auto parameter = *it;
|
||||
std::string parameterString;
|
||||
try {
|
||||
parameter.convert(parameterString);
|
||||
if (parameterString == "EmailVerificationCode.Register") {
|
||||
try {
|
||||
auto emailVerificationCode = controller::EmailVerificationCode::load(
|
||||
userModel->getID(), model::table::EMAIL_OPT_IN_REGISTER
|
||||
);
|
||||
if (!emailVerificationCode) {
|
||||
emailVerificationCode = controller::EmailVerificationCode::create(userModel->getID(), model::table::EMAIL_OPT_IN_REGISTER);
|
||||
UniLib::controller::TaskPtr insert = new model::table::ModelInsertTask(emailVerificationCode->getModel(), false);
|
||||
insert->scheduleTask(insert);
|
||||
}
|
||||
jsonUser.set("EmailVerificationCode.Register", std::to_string(emailVerificationCode->getModel()->getCode()));
|
||||
}
|
||||
catch (Poco::Exception& ex) {
|
||||
printf("exception: %s\n", ex.displayText().data());
|
||||
}
|
||||
}
|
||||
else if (parameterString == "loginServer.path") {
|
||||
jsonServer.set("loginServer.path", ServerConfig::g_serverPath);
|
||||
}
|
||||
else if (parameterString == "user.pubkeyhex") {
|
||||
jsonUser.set("pubkeyhex", userModel->getPublicKeyHex());
|
||||
}
|
||||
else if (parameterString == "user.first_name") {
|
||||
jsonUser.set("first_name", userModel->getFirstName());
|
||||
}
|
||||
else if (parameterString == "user.last_name") {
|
||||
jsonUser.set("last_name", userModel->getLastName());
|
||||
}
|
||||
else if (parameterString == "user.disabled") {
|
||||
jsonUser.set("disabled", userModel->isDisabled());
|
||||
}
|
||||
else if (parameterString == "user.email_checked") {
|
||||
jsonUser.set("email_checked", userModel->isEmailChecked());
|
||||
}
|
||||
else if (parameterString == "user.identHash") {
|
||||
auto email = userModel->getEmail();
|
||||
jsonUser.set("identHash", DRMakeStringHash(email.data(), email.size()));
|
||||
}
|
||||
}
|
||||
catch (Poco::Exception& ex) {
|
||||
jsonErrorsArray.add("ask parameter invalid");
|
||||
}
|
||||
}
|
||||
result->set("errors", jsonErrorsArray);
|
||||
result->set("userData", jsonUser);
|
||||
result->set("server", jsonServer);
|
||||
return result;
|
||||
|
||||
}
|
||||
44
src/cpp/JSONInterface/JsonLogout.cpp
Normal file
44
src/cpp/JSONInterface/JsonLogout.cpp
Normal file
@ -0,0 +1,44 @@
|
||||
#include "JsonLogout.h"
|
||||
|
||||
|
||||
|
||||
#include "../SingletonManager/SessionManager.h"
|
||||
|
||||
|
||||
Poco::JSON::Object* JsonLogout::handle(Poco::Dynamic::Var params)
|
||||
{
|
||||
|
||||
auto sm = SessionManager::getInstance();
|
||||
int session_id = 0;
|
||||
|
||||
// if is json object
|
||||
if (params.type() == typeid(Poco::JSON::Object::Ptr)) {
|
||||
Poco::JSON::Object::Ptr paramJsonObject = params.extract<Poco::JSON::Object::Ptr>();
|
||||
/// Throws a RangeException if the value does not fit
|
||||
/// into the result variable.
|
||||
/// Throws a NotImplementedException if conversion is
|
||||
/// not available for the given type.
|
||||
/// Throws InvalidAccessException if Var is empty.
|
||||
try {
|
||||
paramJsonObject->get("session_id").convert(session_id);
|
||||
}
|
||||
catch (Poco::Exception& ex) {
|
||||
return stateError("json exception", ex.displayText());
|
||||
}
|
||||
}
|
||||
else {
|
||||
return stateError("parameter format unknown");
|
||||
}
|
||||
|
||||
auto session = sm->getSession(session_id);
|
||||
if (!session) {
|
||||
return stateError("session not found", std::to_string(session_id));
|
||||
}
|
||||
if (sm->releaseSession(session_id)) {
|
||||
return stateSuccess();
|
||||
}
|
||||
return stateError("error by releasing session");
|
||||
|
||||
|
||||
|
||||
}
|
||||
18
src/cpp/JSONInterface/JsonLogout.h
Normal file
18
src/cpp/JSONInterface/JsonLogout.h
Normal file
@ -0,0 +1,18 @@
|
||||
#ifndef __JSON_INTERFACE_JSON_LOGOUT_
|
||||
#define __JSON_INTERFACE_JSON_LOGOUT_
|
||||
|
||||
#include "JsonRequestHandler.h"
|
||||
|
||||
class JsonLogout : public JsonRequestHandler
|
||||
{
|
||||
public:
|
||||
JsonLogout(Poco::Net::IPAddress ip) : mClientIP(ip) {}
|
||||
Poco::JSON::Object* handle(Poco::Dynamic::Var params);
|
||||
|
||||
protected:
|
||||
Poco::Net::IPAddress mClientIP;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // __JSON_INTERFACE_JSON_LOGOUT_
|
||||
@ -8,13 +8,20 @@
|
||||
|
||||
#include "Poco/JSON/Parser.h"
|
||||
|
||||
#include "../ServerConfig.h"
|
||||
|
||||
#include "../lib/DataTypeConverter.h"
|
||||
#include "../SingletonManager/SessionManager.h"
|
||||
|
||||
void JsonRequestHandler::handleRequest(Poco::Net::HTTPServerRequest& request, Poco::Net::HTTPServerResponse& response)
|
||||
{
|
||||
|
||||
response.setChunkedTransferEncoding(false);
|
||||
response.setContentType("application/json");
|
||||
if (ServerConfig::g_AllowUnsecureFlags & ServerConfig::UNSECURE_CORS_ALL) {
|
||||
response.set("Access-Control-Allow-Origin", "*");
|
||||
response.set("Access-Control-Allow-Headers", "Access-Control-Allow-Headers, Origin,Accept, X-Requested-With, Content-Type, Access-Control-Request-Method, Access-Control-Request-Headers");
|
||||
}
|
||||
//bool _compressResponse(request.hasToken("Accept-Encoding", "gzip"));
|
||||
//if (_compressResponse) response.set("Content-Encoding", "gzip");
|
||||
|
||||
@ -32,6 +39,9 @@ void JsonRequestHandler::handleRequest(Poco::Net::HTTPServerRequest& request, Po
|
||||
if (parsedResult.size() != 0) {
|
||||
json_result = handle(parsedResult);
|
||||
}
|
||||
else {
|
||||
json_result = stateError("empty body");
|
||||
}
|
||||
}
|
||||
else if(method == "GET") {
|
||||
Poco::URI uri(request.getURI());
|
||||
@ -40,6 +50,21 @@ void JsonRequestHandler::handleRequest(Poco::Net::HTTPServerRequest& request, Po
|
||||
}
|
||||
|
||||
if (json_result) {
|
||||
if (!json_result->isNull("session_id")) {
|
||||
int session_id = 0;
|
||||
try {
|
||||
json_result->get("session_id").convert(session_id);
|
||||
}
|
||||
catch (Poco::Exception& e) {
|
||||
ErrorList erros;
|
||||
erros.addError(new Error("json request", "invalid session_id"));
|
||||
erros.sendErrorsAsEmail();
|
||||
}
|
||||
if (session_id) {
|
||||
auto session = SessionManager::getInstance()->getSession("session_id");
|
||||
response.addCookie(session->getLoginCookie());
|
||||
}
|
||||
}
|
||||
json_result->stringify(responseStream);
|
||||
delete json_result;
|
||||
}
|
||||
@ -73,9 +98,11 @@ Poco::Dynamic::Var JsonRequestHandler::parseJsonWithErrorPrintFile(std::istream&
|
||||
std::string dateTimeString = Poco::DateTimeFormatter::format(Poco::DateTime(), "%d_%m_%yT%H_%M_%S");
|
||||
std::string filename = dateTimeString + "_response.html";
|
||||
FILE* f = fopen(filename.data(), "wt");
|
||||
std::string responseString = responseStringStream.str();
|
||||
fwrite(responseString.data(), 1, responseString.size(), f);
|
||||
fclose(f);
|
||||
if (f) {
|
||||
std::string responseString = responseStringStream.str();
|
||||
fwrite(responseString.data(), 1, responseString.size(), f);
|
||||
fclose(f);
|
||||
}
|
||||
return Poco::Dynamic::Var();
|
||||
}
|
||||
return Poco::Dynamic::Var();
|
||||
@ -109,4 +136,3 @@ Poco::JSON::Object* JsonRequestHandler::customStateError(const char* state, cons
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@ -13,6 +13,8 @@
|
||||
#include "JsonAdminEmailVerificationResend.h"
|
||||
#include "JsonGetUserInfos.h"
|
||||
#include "JsonUpdateUserInfos.h"
|
||||
#include "JsonUnsecureLogin.h"
|
||||
#include "JsonLogout.h"
|
||||
#include "JsonSearch.h"
|
||||
|
||||
JsonRequestHandlerFactory::JsonRequestHandlerFactory()
|
||||
@ -33,6 +35,12 @@ Poco::Net::HTTPRequestHandler* JsonRequestHandlerFactory::createRequestHandler(c
|
||||
|
||||
mLogging.information(logStream.str());
|
||||
|
||||
auto client_host = request.clientAddress().host();
|
||||
//auto client_ip = request.clientAddress();
|
||||
// X-Real-IP forwarded ip from nginx config
|
||||
auto client_host_string = request.get("X-Real-IP", client_host.toString());
|
||||
client_host = Poco::Net::IPAddress(client_host_string);
|
||||
|
||||
if (url_first_part == "/login") {
|
||||
return new JsonGetLogin;
|
||||
}
|
||||
@ -46,7 +54,7 @@ Poco::Net::HTTPRequestHandler* JsonRequestHandlerFactory::createRequestHandler(c
|
||||
return new JsonGetUsers;
|
||||
}
|
||||
else if (url_first_part == "/createUser") {
|
||||
return new JsonCreateUser;
|
||||
return new JsonCreateUser(client_host);
|
||||
}
|
||||
else if (url_first_part == "/adminEmailVerificationResend") {
|
||||
return new JsonAdminEmailVerificationResend;
|
||||
@ -60,6 +68,11 @@ Poco::Net::HTTPRequestHandler* JsonRequestHandlerFactory::createRequestHandler(c
|
||||
else if (url_first_part == "/search") {
|
||||
return new JsonSearch;
|
||||
}
|
||||
|
||||
else if (url_first_part == "/unsecureLogin" && (ServerConfig::g_AllowUnsecureFlags & ServerConfig::UNSECURE_PASSWORD_REQUESTS)) {
|
||||
return new JsonUnsecureLogin(client_host);
|
||||
}
|
||||
else if (url_first_part == "/logout") {
|
||||
return new JsonLogout(client_host);
|
||||
}
|
||||
return new JsonUnknown;
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
#include "Poco/Dynamic/Struct.h"
|
||||
|
||||
#include "../SingletonManager/SessionManager.h"
|
||||
#include "../ServerConfig.h"
|
||||
|
||||
Poco::JSON::Object* JsonTransaction::handle(Poco::Dynamic::Var params)
|
||||
{
|
||||
@ -30,6 +31,7 @@ Poco::JSON::Object* JsonTransaction::handle(Poco::Dynamic::Var params)
|
||||
}
|
||||
|
||||
int balance = 0;
|
||||
|
||||
if (!paramJsonObject->isNull("balance")) {
|
||||
paramJsonObject->get("balance").convert(balance);
|
||||
if (balance) {
|
||||
@ -43,10 +45,23 @@ Poco::JSON::Object* JsonTransaction::handle(Poco::Dynamic::Var params)
|
||||
std::string transactionBase64String;
|
||||
Poco::Dynamic::Var transaction_base64 = paramJsonObject->get("transaction_base64");
|
||||
int alreadyEnlisted = 0;
|
||||
bool auto_sign = false;
|
||||
auto auto_sign_json = paramJsonObject->get("auto_sign");
|
||||
if (!auto_sign_json.isEmpty()) {
|
||||
auto_sign_json.convert(auto_sign);
|
||||
}
|
||||
|
||||
if (transaction_base64.isString()) {
|
||||
paramJsonObject->get("transaction_base64").convert(transactionBase64String);
|
||||
|
||||
if (!session->startProcessingTransaction(transactionBase64String)) {
|
||||
if (!session->startProcessingTransaction(transactionBase64String, auto_sign)) {
|
||||
if (auto_sign) {
|
||||
auto errorJson = session->getErrorsArray();
|
||||
result->set("state", "error");
|
||||
result->set("msg", "error processing transaction");
|
||||
result->set("details", errorJson);
|
||||
return result;
|
||||
}
|
||||
auto lastError = session->getLastError();
|
||||
if (lastError) delete lastError;
|
||||
result->set("state", "error");
|
||||
@ -56,9 +71,11 @@ Poco::JSON::Object* JsonTransaction::handle(Poco::Dynamic::Var params)
|
||||
|
||||
} else {
|
||||
Poco::DynamicStruct ds = *paramJsonObject;
|
||||
int alreadyEnlisted = 0;
|
||||
|
||||
for (int i = 0; i < ds["transaction_base64"].size(); i++) {
|
||||
ds["transaction_base64"][i].convert(transactionBase64String);
|
||||
if (!session->startProcessingTransaction(transactionBase64String)) {
|
||||
if (!session->startProcessingTransaction(transactionBase64String, auto_sign)) {
|
||||
auto lastError = session->getLastError();
|
||||
if (lastError) delete lastError;
|
||||
alreadyEnlisted++;
|
||||
@ -151,4 +168,4 @@ Poco::JSON::Object* JsonTransaction::handle(Poco::Dynamic::Var params)
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,16 +1,19 @@
|
||||
#ifndef __JSON_INTERFACE_JSON_TRANSACTION_
|
||||
#define __JSON_INTERFACE_JSON_TRANSACTION_
|
||||
|
||||
#include "JsonRequestHandler.h"
|
||||
|
||||
class JsonTransaction : public JsonRequestHandler
|
||||
{
|
||||
public:
|
||||
Poco::JSON::Object* handle(Poco::Dynamic::Var params);
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
};
|
||||
|
||||
#ifndef __JSON_INTERFACE_JSON_TRANSACTION_
|
||||
#define __JSON_INTERFACE_JSON_TRANSACTION_
|
||||
|
||||
#include "JsonRequestHandler.h"
|
||||
|
||||
class Session;
|
||||
|
||||
class JsonTransaction : public JsonRequestHandler
|
||||
{
|
||||
public:
|
||||
Poco::JSON::Object* handle(Poco::Dynamic::Var params);
|
||||
|
||||
protected:
|
||||
bool startProcessingTransaction(Session* session, const std::string& transactionBase64);
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // __JSON_INTERFACE_JSON_TRANSACTION_
|
||||
114
src/cpp/JSONInterface/JsonUnsecureLogin.cpp
Normal file
114
src/cpp/JSONInterface/JsonUnsecureLogin.cpp
Normal file
@ -0,0 +1,114 @@
|
||||
#include "JsonUnsecureLogin.h"
|
||||
|
||||
#include "../SingletonManager/SessionManager.h"
|
||||
#include "../SingletonManager/SingletonTaskObserver.h"
|
||||
#include "../SingletonManager/ErrorManager.h"
|
||||
|
||||
#include "../controller/User.h"
|
||||
|
||||
#include "../lib/DataTypeConverter.h"
|
||||
|
||||
Poco::JSON::Object* JsonUnsecureLogin::handle(Poco::Dynamic::Var params)
|
||||
{
|
||||
|
||||
auto sm = SessionManager::getInstance();
|
||||
auto observer = SingletonTaskObserver::getInstance();
|
||||
auto em = ErrorManager::getInstance();
|
||||
|
||||
/*
|
||||
'username', 'password'
|
||||
*/
|
||||
// incoming
|
||||
|
||||
std::string email;
|
||||
std::string password;
|
||||
|
||||
// if is json object
|
||||
if (params.type() == typeid(Poco::JSON::Object::Ptr)) {
|
||||
Poco::JSON::Object::Ptr paramJsonObject = params.extract<Poco::JSON::Object::Ptr>();
|
||||
/// Throws a RangeException if the value does not fit
|
||||
/// into the result variable.
|
||||
/// Throws a NotImplementedException if conversion is
|
||||
/// not available for the given type.
|
||||
/// Throws InvalidAccessException if Var is empty.
|
||||
try {
|
||||
paramJsonObject->get("email").convert(email);
|
||||
paramJsonObject->get("password").convert(password);
|
||||
}
|
||||
catch (Poco::Exception& ex) {
|
||||
return stateError("json exception", ex.displayText());
|
||||
}
|
||||
}
|
||||
else {
|
||||
return stateError("parameter format unknown");
|
||||
}
|
||||
|
||||
|
||||
if (!email.size() || !sm->isValid(email, VALIDATE_EMAIL)) {
|
||||
return stateError("invalid or empty email");
|
||||
}
|
||||
auto user = controller::User::create();
|
||||
if (1 != user->load(email)) {
|
||||
return stateError("user with email not found", email);
|
||||
}
|
||||
|
||||
ErrorList pwd_errors;
|
||||
Poco::JSON::Object* result = new Poco::JSON::Object;
|
||||
|
||||
if (!password.size() || !sm->checkPwdValidation(password, &pwd_errors)) {
|
||||
|
||||
result->set("state", "error");
|
||||
result->set("msg", pwd_errors.getLastError()->getString(false));
|
||||
if (pwd_errors.errorCount()) {
|
||||
result->set("details", pwd_errors.getLastError()->getString(false));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
auto session = sm->getNewSession();
|
||||
/*
|
||||
USER_EMPTY,
|
||||
USER_LOADED_FROM_DB,
|
||||
USER_PASSWORD_INCORRECT,
|
||||
USER_PASSWORD_ENCRYPTION_IN_PROCESS,
|
||||
USER_EMAIL_NOT_ACTIVATED,
|
||||
USER_NO_KEYS,
|
||||
USER_NO_PRIVATE_KEY,
|
||||
USER_KEYS_DONT_MATCH,
|
||||
USER_COMPLETE,
|
||||
USER_DISABLED
|
||||
*/
|
||||
auto user_state = session->loadUser(email, password);
|
||||
|
||||
switch (user_state) {
|
||||
case USER_EMPTY:
|
||||
case USER_PASSWORD_INCORRECT:
|
||||
result->set("state", "error");
|
||||
result->set("msg", "password incorrect");
|
||||
break;
|
||||
case USER_PASSWORD_ENCRYPTION_IN_PROCESS:
|
||||
result->set("state", "processing");
|
||||
result->set("msg", "password encryption in process");
|
||||
break;
|
||||
case USER_KEYS_DONT_MATCH:
|
||||
result->set("state", "error");
|
||||
result->set("msg", "saved keys mismatch");
|
||||
break;
|
||||
case USER_DISABLED:
|
||||
result->set("state", "disabled");
|
||||
result->set("msg", "user is disabled");
|
||||
break;
|
||||
case USER_NO_PRIVATE_KEY:
|
||||
case USER_COMPLETE:
|
||||
case USER_EMAIL_NOT_ACTIVATED:
|
||||
result->set("state", "success");
|
||||
result->set("session_id", session->getHandle());
|
||||
session->setClientIp(mClientIP);
|
||||
return result;
|
||||
}
|
||||
|
||||
sm->releaseSession(session);
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
18
src/cpp/JSONInterface/JsonUnsecureLogin.h
Normal file
18
src/cpp/JSONInterface/JsonUnsecureLogin.h
Normal file
@ -0,0 +1,18 @@
|
||||
#ifndef __JSON_INTERFACE_JSON_UNSECURE_LOGIN_
|
||||
#define __JSON_INTERFACE_JSON_UNSECURE_LOGIN_
|
||||
|
||||
#include "JsonRequestHandler.h"
|
||||
|
||||
class JsonUnsecureLogin : public JsonRequestHandler
|
||||
{
|
||||
public:
|
||||
JsonUnsecureLogin(Poco::Net::IPAddress ip) : mClientIP(ip) {}
|
||||
Poco::JSON::Object* handle(Poco::Dynamic::Var params);
|
||||
|
||||
protected:
|
||||
Poco::Net::IPAddress mClientIP;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // __JSON_INTERFACE_JSON_UNSECURE_LOGIN_
|
||||
@ -1,333 +1,349 @@
|
||||
#include "ServerConfig.h"
|
||||
#include "Crypto/mnemonic_german.h"
|
||||
#include "Crypto/mnemonic_german2.h"
|
||||
#include "Crypto/mnemonic_bip0039.h"
|
||||
#include "Crypto/DRRandom.h"
|
||||
#include "lib/DataTypeConverter.h"
|
||||
#include "sodium.h"
|
||||
|
||||
|
||||
#include "Poco/Net/SSLManager.h"
|
||||
#include "Poco/Net/KeyConsoleHandler.h"
|
||||
#include "Poco/Net/RejectCertificateHandler.h"
|
||||
#include "Poco/Net/DNS.h"
|
||||
#include "Poco/SharedPtr.h"
|
||||
|
||||
#include "Poco/Mutex.h"
|
||||
#include "Poco/Path.h"
|
||||
#include "Poco/FileStream.h"
|
||||
#include "Poco/LocalDateTime.h"
|
||||
#include "Poco/DateTimeFormat.h"
|
||||
#include "Poco/DateTimeFormatter.h"
|
||||
|
||||
|
||||
using Poco::Net::SSLManager;
|
||||
using Poco::Net::Context;
|
||||
using Poco::Net::KeyConsoleHandler;
|
||||
using Poco::Net::PrivateKeyPassphraseHandler;
|
||||
using Poco::Net::InvalidCertificateHandler;
|
||||
using Poco::Net::RejectCertificateHandler;
|
||||
using Poco::SharedPtr;
|
||||
|
||||
namespace ServerConfig {
|
||||
|
||||
#define SESSION_TIMEOUT_DEFAULT 10
|
||||
|
||||
Mnemonic g_Mnemonic_WordLists[MNEMONIC_MAX];
|
||||
ObfusArray* g_ServerCryptoKey = nullptr;
|
||||
ObfusArray* g_ServerKeySeed = nullptr;
|
||||
// std::string g_ServerAdminPublic;
|
||||
UniLib::controller::CPUSheduler* g_CPUScheduler = nullptr;
|
||||
UniLib::controller::CPUSheduler* g_CryptoCPUScheduler = nullptr;
|
||||
Context::Ptr g_SSL_CLient_Context = nullptr;
|
||||
Poco::Util::Timer g_CronJobsTimer;
|
||||
EmailAccount g_EmailAccount;
|
||||
int g_SessionTimeout = SESSION_TIMEOUT_DEFAULT;
|
||||
std::string g_serverPath;
|
||||
int g_serverPort = 0;
|
||||
Languages g_default_locale;
|
||||
std::string g_php_serverPath;
|
||||
std::string g_php_serverHost;
|
||||
int g_phpServerPort;
|
||||
Poco::Mutex g_TimeMutex;
|
||||
int g_FakeLoginSleepTime = 820;
|
||||
std::string g_versionString = "";
|
||||
bool g_disableEmail = false;
|
||||
ServerSetupType g_ServerSetupType = SERVER_TYPE_PRODUCTION;
|
||||
std::string g_gRPCRelayServerFullURL;
|
||||
MemoryBin* g_CryptoAppSecret = nullptr;
|
||||
|
||||
#ifdef __linux__
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <ifaddrs.h>
|
||||
#include <netinet/in.h>
|
||||
#include <string.h>
|
||||
#include <arpa/inet.h>
|
||||
#endif //#ifdef __linux__
|
||||
|
||||
std::string getHostIpString()
|
||||
{
|
||||
#ifdef __linux__
|
||||
struct ifaddrs * ifAddrStruct = NULL;
|
||||
struct ifaddrs * ifa = NULL;
|
||||
void * tmpAddrPtr = NULL;
|
||||
|
||||
getifaddrs(&ifAddrStruct);
|
||||
std::string ipAddressString;
|
||||
|
||||
for (ifa = ifAddrStruct; ifa != NULL; ifa = ifa->ifa_next) {
|
||||
if (!ifa->ifa_addr) {
|
||||
continue;
|
||||
}
|
||||
if (ifa->ifa_addr->sa_family == AF_INET) { // check it is IP4
|
||||
// is a valid IP4 Address
|
||||
tmpAddrPtr = &((struct sockaddr_in *)ifa->ifa_addr)->sin_addr;
|
||||
char addressBuffer[INET_ADDRSTRLEN];
|
||||
inet_ntop(AF_INET, tmpAddrPtr, addressBuffer, INET_ADDRSTRLEN);
|
||||
ipAddressString = addressBuffer;
|
||||
printf("%s IP Address %s\n", ifa->ifa_name, addressBuffer);
|
||||
}
|
||||
else if (ifa->ifa_addr->sa_family == AF_INET6) { // check it is IP6
|
||||
// is a valid IP6 Address
|
||||
tmpAddrPtr = &((struct sockaddr_in6 *)ifa->ifa_addr)->sin6_addr;
|
||||
char addressBuffer[INET6_ADDRSTRLEN];
|
||||
inet_ntop(AF_INET6, tmpAddrPtr, addressBuffer, INET6_ADDRSTRLEN);
|
||||
printf("%s IP Address %s\n", ifa->ifa_name, addressBuffer);
|
||||
}
|
||||
}
|
||||
if (ifAddrStruct != NULL) freeifaddrs(ifAddrStruct);
|
||||
return ipAddressString;
|
||||
#else //__linux__
|
||||
std::string ipAddressString = "";
|
||||
auto host = Poco::Net::DNS::thisHost();
|
||||
for (auto it = host.addresses().begin(); it != host.addresses().end(); it++) {
|
||||
auto ipAddress = *it;
|
||||
if (!ipAddress.isIPv4Compatible() && !ipAddress.isIPv4Mapped()) {
|
||||
continue;
|
||||
}
|
||||
if (ipAddress.isLoopback()) {
|
||||
continue;
|
||||
}
|
||||
ipAddressString = ipAddress.toString();
|
||||
//isIPv4Compatible
|
||||
//!isLoopback
|
||||
//printf("ipaddress: %s\n", ipAddressString.data());
|
||||
break;
|
||||
//break;
|
||||
}
|
||||
return ipAddressString;
|
||||
#endif // __linux__
|
||||
}
|
||||
|
||||
bool replaceZeroIPWithLocalhostIP(std::string& url)
|
||||
{
|
||||
auto pos = url.find("0.0.0.0", 0);
|
||||
if (pos != std::string::npos) {
|
||||
std::string ipAddressString = getHostIpString();
|
||||
if ("" != ipAddressString) {
|
||||
url.replace(pos, 7, ipAddressString);
|
||||
}
|
||||
}
|
||||
|
||||
//printf("ipaddress: %s\n", ipAddress.data());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
ServerSetupType getServerSetupTypeFromString(const std::string& serverSetupTypeString) {
|
||||
if ("test" == serverSetupTypeString) {
|
||||
return SERVER_TYPE_TEST;
|
||||
}
|
||||
if ("staging" == serverSetupTypeString) {
|
||||
return SERVER_TYPE_STAGING;
|
||||
}
|
||||
if ("production" == serverSetupTypeString) {
|
||||
return SERVER_TYPE_PRODUCTION;
|
||||
}
|
||||
return SERVER_TYPE_PRODUCTION;
|
||||
}
|
||||
|
||||
|
||||
bool loadMnemonicWordLists()
|
||||
{
|
||||
for (int i = 0; i < MNEMONIC_MAX; i++) {
|
||||
int iResult = 0;
|
||||
switch (i) {
|
||||
case MNEMONIC_GRADIDO_BOOK_GERMAN_RANDOM_ORDER:
|
||||
iResult = g_Mnemonic_WordLists[i].init(populate_mnemonic_german, g_mnemonic_german_original_size, g_mnemonic_german_compressed_size);
|
||||
if (iResult) {
|
||||
printf("[%s] error init german mnemonic set, error nr: %d\n", __FUNCTION__, iResult);
|
||||
return false;
|
||||
}
|
||||
g_Mnemonic_WordLists[i].printToFile("de_words.txt");
|
||||
break;
|
||||
case MNEMONIC_GRADIDO_BOOK_GERMAN_RANDOM_ORDER_FIXED_CASES:
|
||||
iResult = g_Mnemonic_WordLists[i].init(populate_mnemonic_german2, g_mnemonic_german2_original_size, g_mnemonic_german2_compressed_size);
|
||||
if (iResult) {
|
||||
printf("[%s] error init german mnemonic set 2, error nr: %d\n", __FUNCTION__, iResult);
|
||||
return false;
|
||||
}
|
||||
g_Mnemonic_WordLists[i].printToFile("de_words2.txt");
|
||||
break;
|
||||
case MNEMONIC_BIP0039_SORTED_ORDER:
|
||||
iResult = g_Mnemonic_WordLists[i].init(populate_mnemonic_bip0039, g_mnemonic_bip0039_original_size, g_mnemonic_bip0039_compressed_size);
|
||||
if (iResult) {
|
||||
printf("[%s] error init bip0039 mnemonic set, error nr: %d\n", __FUNCTION__, iResult);
|
||||
return false;
|
||||
}
|
||||
//g_Mnemonic_WordLists[i].printToFile("en_words.txt");
|
||||
break;
|
||||
default: printf("[%s] unknown MnemonicType\n", __FUNCTION__); return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool initServerCrypto(const Poco::Util::LayeredConfiguration& cfg)
|
||||
{
|
||||
auto serverKey = cfg.getString("crypto.server_key");
|
||||
unsigned char key[crypto_shorthash_KEYBYTES];
|
||||
size_t realBinSize = 0;
|
||||
NULLPAD_10;
|
||||
if (sodium_hex2bin(key, crypto_shorthash_KEYBYTES, serverKey.data(), serverKey.size(), nullptr, &realBinSize, nullptr)) {
|
||||
printf("[%s] serverKey isn't valid hex: %s\n", __FUNCTION__, serverKey.data());
|
||||
return false;
|
||||
}
|
||||
if (realBinSize != crypto_shorthash_KEYBYTES) {
|
||||
printf("[%s] serverKey hasn't valid size, expecting: %u, get: %lu\n",
|
||||
__FUNCTION__, crypto_shorthash_KEYBYTES, realBinSize);
|
||||
return false;
|
||||
}
|
||||
g_ServerCryptoKey = new ObfusArray(realBinSize, key);
|
||||
g_ServerKeySeed = new ObfusArray(9*8);
|
||||
Poco::Int64 i1 = randombytes_random();
|
||||
Poco::Int64 i2 = randombytes_random();
|
||||
g_ServerKeySeed->put(0, i1 | (i2 << 8));
|
||||
|
||||
//g_ServerAdminPublic = cfg.getString("crypto.server_admin_public");
|
||||
|
||||
DISASM_FALSERET;
|
||||
g_SessionTimeout = cfg.getInt("session.timeout", SESSION_TIMEOUT_DEFAULT);
|
||||
g_serverPath = cfg.getString("loginServer.path", "");
|
||||
replaceZeroIPWithLocalhostIP(g_serverPath);
|
||||
g_default_locale = LanguageManager::languageFromString(cfg.getString("loginServer.default_locale"));
|
||||
g_serverPort = cfg.getInt("loginServer.port", 0);
|
||||
g_phpServerPort = cfg.getInt("phpServer.port", 0);
|
||||
// replace 0.0.0.0 with actual server ip
|
||||
|
||||
g_php_serverPath = cfg.getString("phpServer.url", "");
|
||||
replaceZeroIPWithLocalhostIP(g_php_serverPath);
|
||||
g_php_serverHost = cfg.getString("phpServer.host", "");
|
||||
replaceZeroIPWithLocalhostIP(g_php_serverHost);
|
||||
//g_ServerSetupType
|
||||
auto serverSetupTypeString = cfg.getString("ServerSetupType", "");
|
||||
g_ServerSetupType = getServerSetupTypeFromString(serverSetupTypeString);
|
||||
|
||||
// app secret for encrypt user private keys
|
||||
// TODO: encrypt with server admin key
|
||||
auto app_secret_string = cfg.getString("crypto.app_secret", "");
|
||||
if ("" != app_secret_string) {
|
||||
g_CryptoAppSecret = DataTypeConverter::hexToBin(app_secret_string);
|
||||
}
|
||||
//g_CryptoAppSecret
|
||||
|
||||
g_gRPCRelayServerFullURL = cfg.getString("grpc.server", "");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool initEMailAccount(const Poco::Util::LayeredConfiguration& cfg)
|
||||
{
|
||||
g_disableEmail = cfg.getBool("email.disable", false);
|
||||
if (g_disableEmail) {
|
||||
printf("Email is disabled!\n");
|
||||
}
|
||||
else {
|
||||
g_EmailAccount.sender = cfg.getString("email.sender");
|
||||
g_EmailAccount.username = cfg.getString("email.username");
|
||||
g_EmailAccount.password = cfg.getString("email.password");
|
||||
g_EmailAccount.url = cfg.getString("email.smtp.url");
|
||||
g_EmailAccount.port = cfg.getInt("email.smtp.port");
|
||||
}
|
||||
DISASM_FALSERET;
|
||||
//g_ServerKeySeed->put(3, DRRandom::r64());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool initSSLClientContext()
|
||||
{
|
||||
SharedPtr<InvalidCertificateHandler> pCert = new RejectCertificateHandler(false); // reject invalid certificates
|
||||
/*
|
||||
Context(Usage usage,
|
||||
const std::string& certificateNameOrPath,
|
||||
VerificationMode verMode = VERIFY_RELAXED,
|
||||
int options = OPT_DEFAULTS,
|
||||
const std::string& certificateStoreName = CERT_STORE_MY);
|
||||
*/
|
||||
try {
|
||||
#ifdef POCO_NETSSL_WIN
|
||||
g_SSL_CLient_Context = new Context(Context::CLIENT_USE, "cacert.pem", Context::VERIFY_RELAXED, Context::OPT_DEFAULTS);
|
||||
#else
|
||||
|
||||
g_SSL_CLient_Context = new Context(Context::CLIENT_USE, "", "", Poco::Path::config() + "grd_login/cacert.pem", Context::VERIFY_RELAXED, 9, true, "ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH");
|
||||
#endif
|
||||
} catch(Poco::Exception& ex) {
|
||||
printf("[ServerConfig::initSSLClientContext] error init ssl context, maybe no cacert.pem found?\nPlease make sure you have cacert.pem (CA/root certificates) next to binary from https://curl.haxx.se/docs/caextract.html\n");
|
||||
return false;
|
||||
}
|
||||
DISASM_FALSERET;
|
||||
SSLManager::instance().initializeClient(0, pCert, g_SSL_CLient_Context);
|
||||
|
||||
g_ServerKeySeed->put(5, DRRandom::r64());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void unload() {
|
||||
if (g_ServerCryptoKey) {
|
||||
delete g_ServerCryptoKey;
|
||||
}
|
||||
if (g_ServerKeySeed) {
|
||||
delete g_ServerKeySeed;
|
||||
}
|
||||
if (g_CPUScheduler) {
|
||||
delete g_CPUScheduler;
|
||||
}
|
||||
|
||||
if (g_CryptoCPUScheduler) {
|
||||
delete g_CryptoCPUScheduler;
|
||||
}
|
||||
if (g_CryptoAppSecret) {
|
||||
MemoryManager::getInstance()->releaseMemory(g_CryptoAppSecret);
|
||||
g_CryptoAppSecret = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void writeToFile(std::istream& datas, std::string fileName)
|
||||
{
|
||||
static Poco::Mutex mutex;
|
||||
|
||||
mutex.lock();
|
||||
|
||||
Poco::FileOutputStream file(fileName, std::ios::out | std::ios::app);
|
||||
|
||||
if (!file.good()) {
|
||||
printf("[ServerConfig::writeToFile] error creating file with name: %s\n", fileName.data());
|
||||
mutex.unlock();
|
||||
return;
|
||||
}
|
||||
|
||||
Poco::LocalDateTime now;
|
||||
|
||||
std::string dateTimeStr = Poco::DateTimeFormatter::format(now, Poco::DateTimeFormat::ISO8601_FORMAT);
|
||||
file << dateTimeStr << std::endl;
|
||||
|
||||
for (std::string line; std::getline(datas, line); ) {
|
||||
file << line << std::endl;
|
||||
}
|
||||
file << std::endl;
|
||||
file.close();
|
||||
mutex.unlock();
|
||||
}
|
||||
#include "ServerConfig.h"
|
||||
#include "Crypto/mnemonic_german.h"
|
||||
#include "Crypto/mnemonic_german2.h"
|
||||
#include "Crypto/mnemonic_bip0039.h"
|
||||
#include "Crypto/DRRandom.h"
|
||||
#include "lib/DataTypeConverter.h"
|
||||
#include "sodium.h"
|
||||
|
||||
|
||||
#include "Poco/Net/SSLManager.h"
|
||||
#include "Poco/Net/KeyConsoleHandler.h"
|
||||
#include "Poco/Net/RejectCertificateHandler.h"
|
||||
#include "Poco/Net/DNS.h"
|
||||
#include "Poco/SharedPtr.h"
|
||||
|
||||
#include "Poco/Mutex.h"
|
||||
#include "Poco/Path.h"
|
||||
#include "Poco/FileStream.h"
|
||||
#include "Poco/LocalDateTime.h"
|
||||
#include "Poco/DateTimeFormat.h"
|
||||
#include "Poco/DateTimeFormatter.h"
|
||||
|
||||
|
||||
using Poco::Net::SSLManager;
|
||||
using Poco::Net::Context;
|
||||
using Poco::Net::KeyConsoleHandler;
|
||||
using Poco::Net::PrivateKeyPassphraseHandler;
|
||||
using Poco::Net::InvalidCertificateHandler;
|
||||
using Poco::Net::RejectCertificateHandler;
|
||||
using Poco::SharedPtr;
|
||||
|
||||
namespace ServerConfig {
|
||||
|
||||
#define SESSION_TIMEOUT_DEFAULT 10
|
||||
|
||||
Mnemonic g_Mnemonic_WordLists[MNEMONIC_MAX];
|
||||
ObfusArray* g_ServerCryptoKey = nullptr;
|
||||
ObfusArray* g_ServerKeySeed = nullptr;
|
||||
// std::string g_ServerAdminPublic;
|
||||
UniLib::controller::CPUSheduler* g_CPUScheduler = nullptr;
|
||||
UniLib::controller::CPUSheduler* g_CryptoCPUScheduler = nullptr;
|
||||
Context::Ptr g_SSL_CLient_Context = nullptr;
|
||||
Poco::Util::Timer g_CronJobsTimer;
|
||||
EmailAccount g_EmailAccount;
|
||||
int g_SessionTimeout = SESSION_TIMEOUT_DEFAULT;
|
||||
std::string g_serverPath;
|
||||
int g_serverPort = 0;
|
||||
Languages g_default_locale;
|
||||
std::string g_php_serverPath;
|
||||
std::string g_php_serverHost;
|
||||
int g_phpServerPort;
|
||||
Poco::Mutex g_TimeMutex;
|
||||
int g_FakeLoginSleepTime = 820;
|
||||
std::string g_versionString = "";
|
||||
bool g_disableEmail = false;
|
||||
ServerSetupType g_ServerSetupType = SERVER_TYPE_PRODUCTION;
|
||||
std::string g_gRPCRelayServerFullURL;
|
||||
MemoryBin* g_CryptoAppSecret = nullptr;
|
||||
AllowUnsecure g_AllowUnsecureFlags = NOT_UNSECURE;
|
||||
|
||||
#ifdef __linux__
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <ifaddrs.h>
|
||||
#include <netinet/in.h>
|
||||
#include <string.h>
|
||||
#include <arpa/inet.h>
|
||||
#endif //#ifdef __linux__
|
||||
|
||||
std::string getHostIpString()
|
||||
{
|
||||
#ifdef __linux__
|
||||
struct ifaddrs * ifAddrStruct = NULL;
|
||||
struct ifaddrs * ifa = NULL;
|
||||
void * tmpAddrPtr = NULL;
|
||||
|
||||
getifaddrs(&ifAddrStruct);
|
||||
std::string ipAddressString;
|
||||
|
||||
for (ifa = ifAddrStruct; ifa != NULL; ifa = ifa->ifa_next) {
|
||||
if (!ifa->ifa_addr) {
|
||||
continue;
|
||||
}
|
||||
if (ifa->ifa_addr->sa_family == AF_INET) { // check it is IP4
|
||||
// is a valid IP4 Address
|
||||
tmpAddrPtr = &((struct sockaddr_in *)ifa->ifa_addr)->sin_addr;
|
||||
char addressBuffer[INET_ADDRSTRLEN];
|
||||
inet_ntop(AF_INET, tmpAddrPtr, addressBuffer, INET_ADDRSTRLEN);
|
||||
ipAddressString = addressBuffer;
|
||||
printf("%s IP Address %s\n", ifa->ifa_name, addressBuffer);
|
||||
}
|
||||
else if (ifa->ifa_addr->sa_family == AF_INET6) { // check it is IP6
|
||||
// is a valid IP6 Address
|
||||
tmpAddrPtr = &((struct sockaddr_in6 *)ifa->ifa_addr)->sin6_addr;
|
||||
char addressBuffer[INET6_ADDRSTRLEN];
|
||||
inet_ntop(AF_INET6, tmpAddrPtr, addressBuffer, INET6_ADDRSTRLEN);
|
||||
printf("%s IP Address %s\n", ifa->ifa_name, addressBuffer);
|
||||
}
|
||||
}
|
||||
if (ifAddrStruct != NULL) freeifaddrs(ifAddrStruct);
|
||||
return ipAddressString;
|
||||
#else //__linux__
|
||||
std::string ipAddressString = "";
|
||||
auto host = Poco::Net::DNS::thisHost();
|
||||
for (auto it = host.addresses().begin(); it != host.addresses().end(); it++) {
|
||||
auto ipAddress = *it;
|
||||
if (!ipAddress.isIPv4Compatible() && !ipAddress.isIPv4Mapped()) {
|
||||
continue;
|
||||
}
|
||||
if (ipAddress.isLoopback()) {
|
||||
continue;
|
||||
}
|
||||
ipAddressString = ipAddress.toString();
|
||||
//isIPv4Compatible
|
||||
//!isLoopback
|
||||
//printf("ipaddress: %s\n", ipAddressString.data());
|
||||
break;
|
||||
//break;
|
||||
}
|
||||
return ipAddressString;
|
||||
#endif // __linux__
|
||||
}
|
||||
|
||||
bool replaceZeroIPWithLocalhostIP(std::string& url)
|
||||
{
|
||||
auto pos = url.find("0.0.0.0", 0);
|
||||
if (pos != std::string::npos) {
|
||||
std::string ipAddressString = getHostIpString();
|
||||
if ("" != ipAddressString) {
|
||||
url.replace(pos, 7, ipAddressString);
|
||||
}
|
||||
}
|
||||
|
||||
//printf("ipaddress: %s\n", ipAddress.data());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
ServerSetupType getServerSetupTypeFromString(const std::string& serverSetupTypeString) {
|
||||
if ("test" == serverSetupTypeString) {
|
||||
return SERVER_TYPE_TEST;
|
||||
}
|
||||
if ("staging" == serverSetupTypeString) {
|
||||
return SERVER_TYPE_STAGING;
|
||||
}
|
||||
if ("production" == serverSetupTypeString) {
|
||||
return SERVER_TYPE_PRODUCTION;
|
||||
}
|
||||
return SERVER_TYPE_PRODUCTION;
|
||||
}
|
||||
|
||||
|
||||
bool loadMnemonicWordLists()
|
||||
{
|
||||
for (int i = 0; i < MNEMONIC_MAX; i++) {
|
||||
int iResult = 0;
|
||||
switch (i) {
|
||||
case MNEMONIC_GRADIDO_BOOK_GERMAN_RANDOM_ORDER:
|
||||
iResult = g_Mnemonic_WordLists[i].init(populate_mnemonic_german, g_mnemonic_german_original_size, g_mnemonic_german_compressed_size);
|
||||
if (iResult) {
|
||||
printf("[%s] error init german mnemonic set, error nr: %d\n", __FUNCTION__, iResult);
|
||||
return false;
|
||||
}
|
||||
g_Mnemonic_WordLists[i].printToFile("de_words.txt");
|
||||
break;
|
||||
case MNEMONIC_GRADIDO_BOOK_GERMAN_RANDOM_ORDER_FIXED_CASES:
|
||||
iResult = g_Mnemonic_WordLists[i].init(populate_mnemonic_german2, g_mnemonic_german2_original_size, g_mnemonic_german2_compressed_size);
|
||||
if (iResult) {
|
||||
printf("[%s] error init german mnemonic set 2, error nr: %d\n", __FUNCTION__, iResult);
|
||||
return false;
|
||||
}
|
||||
g_Mnemonic_WordLists[i].printToFile("de_words2.txt");
|
||||
break;
|
||||
case MNEMONIC_BIP0039_SORTED_ORDER:
|
||||
iResult = g_Mnemonic_WordLists[i].init(populate_mnemonic_bip0039, g_mnemonic_bip0039_original_size, g_mnemonic_bip0039_compressed_size);
|
||||
if (iResult) {
|
||||
printf("[%s] error init bip0039 mnemonic set, error nr: %d\n", __FUNCTION__, iResult);
|
||||
return false;
|
||||
}
|
||||
//g_Mnemonic_WordLists[i].printToFile("en_words.txt");
|
||||
break;
|
||||
default: printf("[%s] unknown MnemonicType\n", __FUNCTION__); return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool initServerCrypto(const Poco::Util::LayeredConfiguration& cfg)
|
||||
{
|
||||
auto serverKey = cfg.getString("crypto.server_key");
|
||||
unsigned char key[crypto_shorthash_KEYBYTES];
|
||||
size_t realBinSize = 0;
|
||||
NULLPAD_10;
|
||||
if (sodium_hex2bin(key, crypto_shorthash_KEYBYTES, serverKey.data(), serverKey.size(), nullptr, &realBinSize, nullptr)) {
|
||||
printf("[%s] serverKey isn't valid hex: %s\n", __FUNCTION__, serverKey.data());
|
||||
return false;
|
||||
}
|
||||
if (realBinSize != crypto_shorthash_KEYBYTES) {
|
||||
printf("[%s] serverKey hasn't valid size, expecting: %u, get: %lu\n",
|
||||
__FUNCTION__, crypto_shorthash_KEYBYTES, realBinSize);
|
||||
return false;
|
||||
}
|
||||
g_ServerCryptoKey = new ObfusArray(realBinSize, key);
|
||||
g_ServerKeySeed = new ObfusArray(9*8);
|
||||
Poco::Int64 i1 = randombytes_random();
|
||||
Poco::Int64 i2 = randombytes_random();
|
||||
g_ServerKeySeed->put(0, i1 | (i2 << 8));
|
||||
|
||||
//g_ServerAdminPublic = cfg.getString("crypto.server_admin_public");
|
||||
|
||||
DISASM_FALSERET;
|
||||
g_SessionTimeout = cfg.getInt("session.timeout", SESSION_TIMEOUT_DEFAULT);
|
||||
g_serverPath = cfg.getString("loginServer.path", "");
|
||||
replaceZeroIPWithLocalhostIP(g_serverPath);
|
||||
g_default_locale = LanguageManager::languageFromString(cfg.getString("loginServer.default_locale"));
|
||||
g_serverPort = cfg.getInt("loginServer.port", 0);
|
||||
g_phpServerPort = cfg.getInt("phpServer.port", 0);
|
||||
// replace 0.0.0.0 with actual server ip
|
||||
|
||||
g_php_serverPath = cfg.getString("phpServer.url", "");
|
||||
replaceZeroIPWithLocalhostIP(g_php_serverPath);
|
||||
g_php_serverHost = cfg.getString("phpServer.host", "");
|
||||
replaceZeroIPWithLocalhostIP(g_php_serverHost);
|
||||
//g_ServerSetupType
|
||||
auto serverSetupTypeString = cfg.getString("ServerSetupType", "");
|
||||
g_ServerSetupType = getServerSetupTypeFromString(serverSetupTypeString);
|
||||
|
||||
// app secret for encrypt user private keys
|
||||
// TODO: encrypt with server admin key
|
||||
auto app_secret_string = cfg.getString("crypto.app_secret", "");
|
||||
if ("" != app_secret_string) {
|
||||
g_CryptoAppSecret = DataTypeConverter::hexToBin(app_secret_string);
|
||||
}
|
||||
//g_CryptoAppSecret
|
||||
|
||||
g_gRPCRelayServerFullURL = cfg.getString("grpc.server", "");
|
||||
|
||||
// unsecure flags
|
||||
//g_AllowUnsecureFlags
|
||||
if (cfg.getInt("unsecure.allow_passwort_via_json_request", 0) == 1) {
|
||||
g_AllowUnsecureFlags = (AllowUnsecure)(g_AllowUnsecureFlags | UNSECURE_PASSWORD_REQUESTS);
|
||||
}
|
||||
if (cfg.getInt("unsecure.allow_auto_sign_transactions", 0) == 1) {
|
||||
g_AllowUnsecureFlags = (AllowUnsecure)(g_AllowUnsecureFlags | UNSECURE_AUTO_SIGN_TRANSACTIONS);
|
||||
}
|
||||
if (cfg.getInt("unsecure.allow_cors_all", 0) == 1) {
|
||||
g_AllowUnsecureFlags = (AllowUnsecure)(g_AllowUnsecureFlags | UNSECURE_CORS_ALL);
|
||||
}
|
||||
if (cfg.getInt("unsecure.allow_all_passwords", 0) == 1) {
|
||||
g_AllowUnsecureFlags = (AllowUnsecure)(g_AllowUnsecureFlags | UNSECURE_ALLOW_ALL_PASSWORDS);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool initEMailAccount(const Poco::Util::LayeredConfiguration& cfg)
|
||||
{
|
||||
g_disableEmail = cfg.getBool("email.disable", false);
|
||||
if (g_disableEmail) {
|
||||
printf("Email is disabled!\n");
|
||||
}
|
||||
else {
|
||||
g_EmailAccount.sender = cfg.getString("email.sender");
|
||||
g_EmailAccount.username = cfg.getString("email.username");
|
||||
g_EmailAccount.password = cfg.getString("email.password");
|
||||
g_EmailAccount.url = cfg.getString("email.smtp.url");
|
||||
g_EmailAccount.port = cfg.getInt("email.smtp.port");
|
||||
}
|
||||
DISASM_FALSERET;
|
||||
//g_ServerKeySeed->put(3, DRRandom::r64());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool initSSLClientContext()
|
||||
{
|
||||
SharedPtr<InvalidCertificateHandler> pCert = new RejectCertificateHandler(false); // reject invalid certificates
|
||||
/*
|
||||
Context(Usage usage,
|
||||
const std::string& certificateNameOrPath,
|
||||
VerificationMode verMode = VERIFY_RELAXED,
|
||||
int options = OPT_DEFAULTS,
|
||||
const std::string& certificateStoreName = CERT_STORE_MY);
|
||||
*/
|
||||
try {
|
||||
#ifdef POCO_NETSSL_WIN
|
||||
g_SSL_CLient_Context = new Context(Context::CLIENT_USE, "cacert.pem", Context::VERIFY_RELAXED, Context::OPT_DEFAULTS);
|
||||
#else
|
||||
|
||||
g_SSL_CLient_Context = new Context(Context::CLIENT_USE, "", "", Poco::Path::config() + "grd_login/cacert.pem", Context::VERIFY_RELAXED, 9, true, "ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH");
|
||||
#endif
|
||||
} catch(Poco::Exception& ex) {
|
||||
printf("[ServerConfig::initSSLClientContext] error init ssl context, maybe no cacert.pem found?\nPlease make sure you have cacert.pem (CA/root certificates) next to binary from https://curl.haxx.se/docs/caextract.html\n");
|
||||
return false;
|
||||
}
|
||||
DISASM_FALSERET;
|
||||
SSLManager::instance().initializeClient(0, pCert, g_SSL_CLient_Context);
|
||||
|
||||
g_ServerKeySeed->put(5, DRRandom::r64());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void unload() {
|
||||
if (g_ServerCryptoKey) {
|
||||
delete g_ServerCryptoKey;
|
||||
}
|
||||
if (g_ServerKeySeed) {
|
||||
delete g_ServerKeySeed;
|
||||
}
|
||||
if (g_CPUScheduler) {
|
||||
delete g_CPUScheduler;
|
||||
}
|
||||
|
||||
if (g_CryptoCPUScheduler) {
|
||||
delete g_CryptoCPUScheduler;
|
||||
}
|
||||
if (g_CryptoAppSecret) {
|
||||
MemoryManager::getInstance()->releaseMemory(g_CryptoAppSecret);
|
||||
g_CryptoAppSecret = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void writeToFile(std::istream& datas, std::string fileName)
|
||||
{
|
||||
static Poco::Mutex mutex;
|
||||
|
||||
mutex.lock();
|
||||
|
||||
Poco::FileOutputStream file(fileName, std::ios::out | std::ios::app);
|
||||
|
||||
if (!file.good()) {
|
||||
printf("[ServerConfig::writeToFile] error creating file with name: %s\n", fileName.data());
|
||||
mutex.unlock();
|
||||
return;
|
||||
}
|
||||
|
||||
Poco::LocalDateTime now;
|
||||
|
||||
std::string dateTimeStr = Poco::DateTimeFormatter::format(now, Poco::DateTimeFormat::ISO8601_FORMAT);
|
||||
file << dateTimeStr << std::endl;
|
||||
|
||||
for (std::string line; std::getline(datas, line); ) {
|
||||
file << line << std::endl;
|
||||
}
|
||||
file << std::endl;
|
||||
file.close();
|
||||
mutex.unlock();
|
||||
}
|
||||
}
|
||||
@ -1,80 +1,90 @@
|
||||
#ifndef __GRADIDO_LOGIN_SERVER_SERVER_CONFIG__
|
||||
#define __GRADIDO_LOGIN_SERVER_SERVER_CONFIG__
|
||||
|
||||
#include "Crypto/mnemonic.h"
|
||||
#include "Crypto/Obfus_array.h"
|
||||
#include "Poco/Util/LayeredConfiguration.h"
|
||||
#include "Poco/Net/Context.h"
|
||||
#include "Poco/Types.h"
|
||||
#include "Poco/Util/Timer.h"
|
||||
|
||||
#include "tasks/CPUSheduler.h"
|
||||
|
||||
#include "SingletonManager/LanguageManager.h"
|
||||
#include "SingletonManager/MemoryManager.h"
|
||||
|
||||
#define DISABLE_EMAIL
|
||||
|
||||
namespace ServerConfig {
|
||||
|
||||
enum Mnemonic_Types {
|
||||
MNEMONIC_GRADIDO_BOOK_GERMAN_RANDOM_ORDER,
|
||||
MNEMONIC_GRADIDO_BOOK_GERMAN_RANDOM_ORDER_FIXED_CASES,
|
||||
MNEMONIC_BIP0039_SORTED_ORDER,
|
||||
MNEMONIC_MAX
|
||||
};
|
||||
// depracted, moved to email manager
|
||||
struct EmailAccount {
|
||||
std::string sender;
|
||||
std::string admin_receiver;
|
||||
std::string username;
|
||||
std::string password;
|
||||
std::string url;
|
||||
int port;
|
||||
};
|
||||
|
||||
enum ServerSetupType {
|
||||
SERVER_TYPE_TEST,
|
||||
SERVER_TYPE_STAGING,
|
||||
SERVER_TYPE_PRODUCTION
|
||||
};
|
||||
|
||||
|
||||
extern Mnemonic g_Mnemonic_WordLists[MNEMONIC_MAX];
|
||||
|
||||
extern ObfusArray* g_ServerCryptoKey;
|
||||
extern ObfusArray* g_ServerKeySeed;
|
||||
|
||||
//extern unsigned char g_ServerAdminPublic[];
|
||||
extern UniLib::controller::CPUSheduler* g_CPUScheduler;
|
||||
extern UniLib::controller::CPUSheduler* g_CryptoCPUScheduler;
|
||||
extern Poco::Net::Context::Ptr g_SSL_CLient_Context;
|
||||
extern Poco::Util::Timer g_CronJobsTimer;
|
||||
extern EmailAccount g_EmailAccount;
|
||||
extern int g_SessionTimeout;
|
||||
extern std::string g_serverPath;
|
||||
extern int g_serverPort;
|
||||
extern Languages g_default_locale;
|
||||
extern std::string g_php_serverPath;
|
||||
extern std::string g_php_serverHost;
|
||||
extern int g_phpServerPort;
|
||||
extern Poco::Mutex g_TimeMutex;
|
||||
extern int g_FakeLoginSleepTime;
|
||||
extern std::string g_versionString;
|
||||
extern bool g_disableEmail;
|
||||
extern ServerSetupType g_ServerSetupType;
|
||||
extern std::string g_gRPCRelayServerFullURL;
|
||||
extern MemoryBin* g_CryptoAppSecret;
|
||||
|
||||
bool loadMnemonicWordLists();
|
||||
bool initServerCrypto(const Poco::Util::LayeredConfiguration& cfg);
|
||||
bool initEMailAccount(const Poco::Util::LayeredConfiguration& cfg);
|
||||
bool initSSLClientContext();
|
||||
|
||||
|
||||
void writeToFile(std::istream& datas, std::string fileName);
|
||||
|
||||
void unload();
|
||||
};
|
||||
|
||||
#ifndef __GRADIDO_LOGIN_SERVER_SERVER_CONFIG__
|
||||
#define __GRADIDO_LOGIN_SERVER_SERVER_CONFIG__
|
||||
|
||||
#include "Crypto/mnemonic.h"
|
||||
#include "Crypto/Obfus_array.h"
|
||||
#include "Poco/Util/LayeredConfiguration.h"
|
||||
#include "Poco/Net/Context.h"
|
||||
#include "Poco/Types.h"
|
||||
#include "Poco/Util/Timer.h"
|
||||
|
||||
#include "tasks/CPUSheduler.h"
|
||||
|
||||
#include "SingletonManager/LanguageManager.h"
|
||||
#include "SingletonManager/MemoryManager.h"
|
||||
|
||||
#define DISABLE_EMAIL
|
||||
|
||||
namespace ServerConfig {
|
||||
|
||||
enum Mnemonic_Types {
|
||||
MNEMONIC_GRADIDO_BOOK_GERMAN_RANDOM_ORDER,
|
||||
MNEMONIC_GRADIDO_BOOK_GERMAN_RANDOM_ORDER_FIXED_CASES,
|
||||
MNEMONIC_BIP0039_SORTED_ORDER,
|
||||
MNEMONIC_MAX
|
||||
};
|
||||
// depracted, moved to email manager
|
||||
struct EmailAccount {
|
||||
std::string sender;
|
||||
std::string admin_receiver;
|
||||
std::string username;
|
||||
std::string password;
|
||||
std::string url;
|
||||
int port;
|
||||
};
|
||||
|
||||
enum ServerSetupType {
|
||||
SERVER_TYPE_TEST,
|
||||
SERVER_TYPE_STAGING,
|
||||
SERVER_TYPE_PRODUCTION
|
||||
};
|
||||
|
||||
// used with bit-operators, so only use numbers with control exactly one bit (1,2,4,8,16...)
|
||||
enum AllowUnsecure {
|
||||
NOT_UNSECURE = 0,
|
||||
UNSECURE_PASSWORD_REQUESTS = 1,
|
||||
UNSECURE_AUTO_SIGN_TRANSACTIONS = 2,
|
||||
UNSECURE_CORS_ALL = 4,
|
||||
UNSECURE_ALLOW_ALL_PASSWORDS = 8
|
||||
};
|
||||
|
||||
|
||||
extern Mnemonic g_Mnemonic_WordLists[MNEMONIC_MAX];
|
||||
|
||||
extern ObfusArray* g_ServerCryptoKey;
|
||||
extern ObfusArray* g_ServerKeySeed;
|
||||
|
||||
//extern unsigned char g_ServerAdminPublic[];
|
||||
extern UniLib::controller::CPUSheduler* g_CPUScheduler;
|
||||
extern UniLib::controller::CPUSheduler* g_CryptoCPUScheduler;
|
||||
extern Poco::Net::Context::Ptr g_SSL_CLient_Context;
|
||||
extern Poco::Util::Timer g_CronJobsTimer;
|
||||
extern EmailAccount g_EmailAccount;
|
||||
extern int g_SessionTimeout;
|
||||
extern std::string g_serverPath;
|
||||
extern int g_serverPort;
|
||||
extern Languages g_default_locale;
|
||||
extern std::string g_php_serverPath;
|
||||
extern std::string g_php_serverHost;
|
||||
extern int g_phpServerPort;
|
||||
extern Poco::Mutex g_TimeMutex;
|
||||
extern int g_FakeLoginSleepTime;
|
||||
extern std::string g_versionString;
|
||||
extern bool g_disableEmail;
|
||||
extern ServerSetupType g_ServerSetupType;
|
||||
extern std::string g_gRPCRelayServerFullURL;
|
||||
extern MemoryBin* g_CryptoAppSecret;
|
||||
extern AllowUnsecure g_AllowUnsecureFlags;
|
||||
|
||||
bool loadMnemonicWordLists();
|
||||
bool initServerCrypto(const Poco::Util::LayeredConfiguration& cfg);
|
||||
bool initEMailAccount(const Poco::Util::LayeredConfiguration& cfg);
|
||||
bool initSSLClientContext();
|
||||
|
||||
|
||||
void writeToFile(std::istream& datas, std::string fileName);
|
||||
|
||||
void unload();
|
||||
};
|
||||
|
||||
#endif //__GRADIDO_LOGIN_SERVER_SERVER_CONFIG__
|
||||
@ -73,9 +73,19 @@ Poco::Data::Session ConnectionManager::getConnection(ConnectionType type)
|
||||
throw Poco::NotFoundException("Connection Type unknown", std::to_string(type));
|
||||
}
|
||||
auto session = mSessionPools.getPool(mSessionPoolNames[type]).get();
|
||||
|
||||
//return mSessionPoolNames[type];
|
||||
/*if (!session.isConnected()) {
|
||||
printf("reconnect called\n");
|
||||
session.reconnect();
|
||||
try {
|
||||
session.reconnect();
|
||||
}
|
||||
catch (Poco::Exception& e) {
|
||||
addError(new ParamError("[ConnectionManager::getConnection]", "reconnect throw exception, try with next new one, without further check", e.displayText()));
|
||||
sendErrorsAsEmail();
|
||||
return mSessionPools.getPool(mSessionPoolNames[type]).get();
|
||||
}
|
||||
|
||||
}*/
|
||||
//std::string dateTimeString = Poco::DateTimeFormatter::format(Poco::DateTime(), "%d.%m.%y %H:%M:%S");
|
||||
//printf("[getConnection] %s impl: %p\n", dateTimeString.data(), session.impl());
|
||||
|
||||
@ -47,6 +47,7 @@ private:
|
||||
std::string mSessionPoolNames[CONNECTION_MAX];
|
||||
Poco::Data::SessionPoolContainer mSessionPools;
|
||||
Poco::FastMutex mWorkingMutex;
|
||||
|
||||
};
|
||||
|
||||
#endif //GRADIDO_LOGIN_SERVER_SINGLETON_MANAGER_CONNECTION_MANAGER_INCLUDE
|
||||
@ -14,7 +14,7 @@ SessionManager* SessionManager::getInstance()
|
||||
}
|
||||
|
||||
SessionManager::SessionManager()
|
||||
: mInitalized(false)
|
||||
: mInitalized(false), mDeadLockedSessionCount(0)
|
||||
{
|
||||
|
||||
}
|
||||
@ -30,7 +30,8 @@ SessionManager::~SessionManager()
|
||||
bool SessionManager::init()
|
||||
{
|
||||
try {
|
||||
Poco::Mutex::ScopedLock _lock(mWorkingMutex, 500);
|
||||
//Poco::Mutex::ScopedLock _lock(mWorkingMutex, 500);
|
||||
mWorkingMutex.tryLock(500);
|
||||
}
|
||||
catch (Poco::TimeoutException &ex) {
|
||||
printf("[SessionManager::init] exception timout mutex: %s\n", ex.displayText().data());
|
||||
@ -43,7 +44,7 @@ bool SessionManager::init()
|
||||
switch (i) {
|
||||
//case VALIDATE_NAME: mValidations[i] = new Poco::RegularExpression("/^[a-zA-Z_ -]{3,}$/"); break;
|
||||
case VALIDATE_NAME: mValidations[i] = new Poco::RegularExpression("^[^<>&;]{3,}$"); break;
|
||||
case VALIDATE_EMAIL: mValidations[i] = new Poco::RegularExpression("^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$"); break;
|
||||
case VALIDATE_EMAIL: mValidations[i] = new Poco::RegularExpression("^[a-zA-Z0-9.!#$%&<EFBFBD>*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$"); break;
|
||||
case VALIDATE_PASSWORD: mValidations[i] = new Poco::RegularExpression("^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[@$!%*?&+-_])[A-Za-z0-9@$!%*?&+-_]{8,}$"); break;
|
||||
case VALIDATE_PASSPHRASE: mValidations[i] = new Poco::RegularExpression("^(?:[a-z]* ){23}[a-z]*\s*$"); break;
|
||||
case VALIDATE_HAS_NUMBER: mValidations[i] = new Poco::RegularExpression(".*[0-9].*"); break;
|
||||
@ -64,14 +65,15 @@ bool SessionManager::init()
|
||||
|
||||
|
||||
mInitalized = true;
|
||||
//mWorkingMutex.unlock();
|
||||
mWorkingMutex.unlock();
|
||||
return true;
|
||||
}
|
||||
|
||||
void SessionManager::deinitalize()
|
||||
{
|
||||
try {
|
||||
Poco::Mutex::ScopedLock _lock(mWorkingMutex, 500);
|
||||
//Poco::Mutex::ScopedLock _lock(mWorkingMutex, 500);
|
||||
mWorkingMutex.tryLock(500);
|
||||
}
|
||||
catch (Poco::TimeoutException &ex) {
|
||||
printf("[SessionManager::deinitalize] exception timout mutex: %s\n", ex.displayText().data());
|
||||
@ -92,9 +94,10 @@ void SessionManager::deinitalize()
|
||||
delete mValidations[i];
|
||||
}
|
||||
|
||||
printf("[SessionManager::deinitalize] count of dead locked sessions: %d\n", mDeadLockedSessionCount);
|
||||
|
||||
mInitalized = false;
|
||||
//mWorkingMutex.unlock();
|
||||
mWorkingMutex.unlock();
|
||||
}
|
||||
|
||||
bool SessionManager::isValid(const std::string& subject, SessionValidationTypes validationType)
|
||||
@ -138,7 +141,8 @@ Session* SessionManager::getNewSession(int* handle)
|
||||
|
||||
// lock
|
||||
try {
|
||||
Poco::Mutex::ScopedLock _lock(mWorkingMutex, 500);
|
||||
//Poco::Mutex::ScopedLock _lock(mWorkingMutex, 500);
|
||||
mWorkingMutex.tryLock(500);
|
||||
}
|
||||
catch (Poco::TimeoutException &ex) {
|
||||
printf("[%s] exception timout mutex: %s\n", functionName, ex.displayText().data());
|
||||
@ -167,6 +171,7 @@ Session* SessionManager::getNewSession(int* handle)
|
||||
*handle = local_handle;
|
||||
}
|
||||
result->setActive(true);
|
||||
mWorkingMutex.unlock();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@ -187,7 +192,7 @@ Session* SessionManager::getNewSession(int* handle)
|
||||
// check if already exist, if get new
|
||||
int newHandle = generateNewUnusedHandle();
|
||||
if (!newHandle) {
|
||||
//mWorkingMutex.unlock();
|
||||
mWorkingMutex.unlock();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -201,6 +206,7 @@ Session* SessionManager::getNewSession(int* handle)
|
||||
*handle = newHandle;
|
||||
}
|
||||
//printf("[SessionManager::getNewSession] handle: %ld, sum: %u\n", newHandle, mRequestSessionMap.size());
|
||||
mWorkingMutex.unlock();
|
||||
return requestSession;
|
||||
|
||||
|
||||
@ -214,7 +220,8 @@ bool SessionManager::releaseSession(int requestHandleSession)
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
Poco::Mutex::ScopedLock _lock(mWorkingMutex, 500);
|
||||
//Poco::Mutex::ScopedLock _lock(mWorkingMutex, 500);
|
||||
mWorkingMutex.tryLock(500);
|
||||
}
|
||||
catch (Poco::TimeoutException &ex) {
|
||||
printf("[SessionManager::releaseSession] exception timout mutex: %s\n", ex.displayText().data());
|
||||
@ -225,10 +232,20 @@ bool SessionManager::releaseSession(int requestHandleSession)
|
||||
auto it = mRequestSessionMap.find(requestHandleSession);
|
||||
if (it == mRequestSessionMap.end()) {
|
||||
//printf("[SessionManager::releaseRequestSession] requestSession with handle: %d not found\n", requestHandleSession);
|
||||
//mWorkingMutex.unlock();
|
||||
mWorkingMutex.unlock();
|
||||
return false;
|
||||
}
|
||||
Session* session = it->second;
|
||||
|
||||
|
||||
// delete session, not reuse as workaround for server freeze bug
|
||||
mRequestSessionMap.erase(requestHandleSession);
|
||||
delete session;
|
||||
mWorkingMutex.unlock();
|
||||
return true;
|
||||
|
||||
|
||||
|
||||
// check if dead locked
|
||||
if (session->tryLock()) {
|
||||
session->unlock();
|
||||
@ -241,6 +258,7 @@ bool SessionManager::releaseSession(int requestHandleSession)
|
||||
errors.sendErrorsAsEmail();
|
||||
mRequestSessionMap.erase(requestHandleSession);
|
||||
delete session;
|
||||
mWorkingMutex.unlock();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -250,6 +268,7 @@ bool SessionManager::releaseSession(int requestHandleSession)
|
||||
if (mEmptyRequestStack.size() > 100) {
|
||||
mRequestSessionMap.erase(requestHandleSession);
|
||||
delete session;
|
||||
mWorkingMutex.unlock();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -260,7 +279,7 @@ bool SessionManager::releaseSession(int requestHandleSession)
|
||||
|
||||
if (!newHandle) {
|
||||
delete session;
|
||||
//mWorkingMutex.unlock();
|
||||
mWorkingMutex.unlock();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -268,13 +287,13 @@ bool SessionManager::releaseSession(int requestHandleSession)
|
||||
mRequestSessionMap.insert(std::pair<int, Session*>(newHandle, session));
|
||||
mEmptyRequestStack.push(newHandle);
|
||||
|
||||
//mWorkingMutex.unlock();
|
||||
|
||||
mWorkingMutex.unlock();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SessionManager::isExist(int requestHandleSession)
|
||||
{
|
||||
static const char* function_name = "SessionManager::isExist";
|
||||
if (!mInitalized) {
|
||||
printf("[SessionManager::%s] not initialized any more\n", __FUNCTION__);
|
||||
return false;
|
||||
@ -282,7 +301,8 @@ bool SessionManager::isExist(int requestHandleSession)
|
||||
bool result = false;
|
||||
//mWorkingMutex.lock();
|
||||
try {
|
||||
Poco::Mutex::ScopedLock _lock(mWorkingMutex, 500);
|
||||
//Poco::Mutex::ScopedLock _lock(mWorkingMutex, 500);
|
||||
mWorkingMutex.tryLock(500);
|
||||
}
|
||||
catch (Poco::TimeoutException &ex) {
|
||||
printf("[SessionManager::isExist] exception timout mutex: %s\n", ex.displayText().data());
|
||||
@ -291,11 +311,17 @@ bool SessionManager::isExist(int requestHandleSession)
|
||||
auto it = mRequestSessionMap.find(requestHandleSession);
|
||||
if (it != mRequestSessionMap.end()) {
|
||||
result = true;
|
||||
if (!it->second->isActive()) {
|
||||
int iResult = it->second->isActive();
|
||||
if (-1 == iResult) {
|
||||
auto em = ErrorManager::getInstance();
|
||||
em->addError(new Error(function_name, "session return locked"));
|
||||
em->sendErrorsAsEmail();
|
||||
}
|
||||
if (0 == iResult) {
|
||||
printf("[SessionManager::isExist] session isn't active\n");
|
||||
}
|
||||
}
|
||||
//mWorkingMutex.unlock();
|
||||
mWorkingMutex.unlock();
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -318,6 +344,7 @@ Session* SessionManager::getSession(const Poco::Net::HTTPServerRequest& request)
|
||||
|
||||
Session* SessionManager::getSession(int handle)
|
||||
{
|
||||
static const char* function_name = "SessionManager::getSession";
|
||||
if (!mInitalized) {
|
||||
printf("[SessionManager::%s] not initialized any more\n", __FUNCTION__);
|
||||
return nullptr;
|
||||
@ -325,7 +352,8 @@ Session* SessionManager::getSession(int handle)
|
||||
if (0 == handle) return nullptr;
|
||||
Session* result = nullptr;
|
||||
try {
|
||||
Poco::Mutex::ScopedLock _lock(mWorkingMutex, 500);
|
||||
//Poco::Mutex::ScopedLock _lock(mWorkingMutex, 500);
|
||||
mWorkingMutex.tryLock(500);
|
||||
}
|
||||
catch (Poco::TimeoutException &ex) {
|
||||
printf("[SessionManager::getSession] exception timout mutex: %s\n", ex.displayText().data());
|
||||
@ -336,16 +364,24 @@ Session* SessionManager::getSession(int handle)
|
||||
if (it != mRequestSessionMap.end()) {
|
||||
printf("[SessionManager::getSession] found existing session, try if active...\n");
|
||||
result = it->second;
|
||||
if (!result->isActive()) {
|
||||
int iResult = result->isActive();
|
||||
if (iResult == -1) {
|
||||
auto em = ErrorManager::getInstance();
|
||||
em->addError(new Error(function_name, "session is locked"));
|
||||
em->sendErrorsAsEmail();
|
||||
mWorkingMutex.unlock();
|
||||
return nullptr;
|
||||
}
|
||||
if (0 == iResult) {
|
||||
//printf("[SessionManager::getSession] session isn't active\n");
|
||||
//mWorkingMutex.unlock();
|
||||
mWorkingMutex.unlock();
|
||||
return nullptr;
|
||||
}
|
||||
//result->setActive(true);
|
||||
result->updateTimeout();
|
||||
}
|
||||
//printf("[SessionManager::getSession] handle: %ld\n", handle);
|
||||
//mWorkingMutex.unlock();
|
||||
mWorkingMutex.unlock();
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -370,7 +406,8 @@ Session* SessionManager::findByUserId(int userId)
|
||||
assert(userId > 0);
|
||||
static const char* function_name = "SessionManager::findByUserId";
|
||||
try {
|
||||
Poco::Mutex::ScopedLock _lock(mWorkingMutex, 500);
|
||||
//Poco::Mutex::ScopedLock _lock(mWorkingMutex, 500);
|
||||
mWorkingMutex.tryLock(500);
|
||||
}
|
||||
catch (Poco::TimeoutException &ex) {
|
||||
printf("[SessionManager::findByUserId] exception timout mutex: %s\n", ex.displayText().data());
|
||||
@ -378,6 +415,14 @@ Session* SessionManager::findByUserId(int userId)
|
||||
}
|
||||
//mWorkingMutex.lock();
|
||||
for (auto it = mRequestSessionMap.begin(); it != mRequestSessionMap.end(); it++) {
|
||||
while (it->second->isDeadLocked())
|
||||
{
|
||||
it = mRequestSessionMap.erase(it);
|
||||
mDeadLockedSessionCount++;
|
||||
auto em = ErrorManager::getInstance();
|
||||
em->addError(new ParamError("SessionManager::findByUserId", "new dead locked session found, sum dead lock sessions:", mDeadLockedSessionCount));
|
||||
em->sendErrorsAsEmail();
|
||||
}
|
||||
auto user = it->second->getNewUser();
|
||||
auto em = ErrorManager::getInstance();
|
||||
if(!user) continue;
|
||||
@ -395,11 +440,11 @@ Session* SessionManager::findByUserId(int userId)
|
||||
}
|
||||
//assert(user->getModel() && user->getModel()->getID());
|
||||
if (userId == user->getModel()->getID()) {
|
||||
mWorkingMutex.unlock();
|
||||
return it->second;
|
||||
}
|
||||
}
|
||||
//mWorkingMutex.unlock();
|
||||
|
||||
mWorkingMutex.unlock();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -408,14 +453,20 @@ std::vector<Session*> SessionManager::findAllByUserId(int userId)
|
||||
assert(userId > 0);
|
||||
std::vector<Session*> result;
|
||||
try {
|
||||
Poco::Mutex::ScopedLock _lock(mWorkingMutex, 500);
|
||||
//Poco::Mutex::ScopedLock _lock(mWorkingMutex, 500);
|
||||
mWorkingMutex.tryLock(500);
|
||||
}
|
||||
catch (Poco::TimeoutException &ex) {
|
||||
printf("[SessionManager::findAllByUserId] exception timout mutex: %s\n", ex.displayText().data());
|
||||
//mWorkingMutex.unlock();
|
||||
return result;
|
||||
}
|
||||
//mWorkingMutex.lock();
|
||||
for (auto it = mRequestSessionMap.begin(); it != mRequestSessionMap.end(); it++) {
|
||||
if (it->second->isDeadLocked()) {
|
||||
it = mRequestSessionMap.erase(it);
|
||||
mDeadLockedSessionCount++;
|
||||
}
|
||||
auto user = it->second->getNewUser();
|
||||
if (userId == user->getModel()->getID()) {
|
||||
//return it->second;
|
||||
@ -423,7 +474,7 @@ std::vector<Session*> SessionManager::findAllByUserId(int userId)
|
||||
}
|
||||
}
|
||||
//mWorkingMutex.unlock();
|
||||
|
||||
mWorkingMutex.unlock();
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -432,29 +483,34 @@ Session* SessionManager::findByEmail(const std::string& email)
|
||||
assert(email.size() > 0);
|
||||
|
||||
try {
|
||||
Poco::Mutex::ScopedLock _lock(mWorkingMutex, 500);
|
||||
//Poco::Mutex::ScopedLock _lock(mWorkingMutex, 500);
|
||||
mWorkingMutex.tryLock(500);
|
||||
}
|
||||
catch (Poco::TimeoutException &ex) {
|
||||
printf("[SessionManager::findByEmail] exception timout mutex: %s\n", ex.displayText().data());
|
||||
//mWorkingMutex.unlock();
|
||||
return nullptr;
|
||||
}
|
||||
//mWorkingMutex.lock();
|
||||
for (auto it = mRequestSessionMap.begin(); it != mRequestSessionMap.end(); it++) {
|
||||
if (it->second->isDeadLocked()) {
|
||||
it = mRequestSessionMap.erase(it);
|
||||
mDeadLockedSessionCount++;
|
||||
}
|
||||
auto user = it->second->getNewUser();
|
||||
if (email == user->getModel()->getEmail()) {
|
||||
return it->second;
|
||||
}
|
||||
}
|
||||
//mWorkingMutex.unlock();
|
||||
|
||||
mWorkingMutex.unlock();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void SessionManager::checkTimeoutSession()
|
||||
{
|
||||
|
||||
try {
|
||||
Poco::Mutex::ScopedLock _lock(mWorkingMutex, 500);
|
||||
//Poco::Mutex::ScopedLock _lock(mWorkingMutex, 500);
|
||||
mWorkingMutex.tryLock(500);
|
||||
}
|
||||
catch (Poco::TimeoutException &ex) {
|
||||
printf("[SessionManager::checkTimeoutSession] exception timeout mutex: %s\n", ex.displayText().data());
|
||||
@ -467,30 +523,32 @@ void SessionManager::checkTimeoutSession()
|
||||
//auto timeout = Poco::Timespan(1, 0);
|
||||
std::stack<int> toRemove;
|
||||
for (auto it = mRequestSessionMap.begin(); it != mRequestSessionMap.end(); it++) {
|
||||
|
||||
if (it->second->tryLock()) {
|
||||
it->second->unlock();
|
||||
// skip already disabled sessions
|
||||
if (!it->second->isActive()) continue;
|
||||
if (!it->second->isActive()) {
|
||||
it->second->unlock();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// skip dead locked sessions
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
Poco::Timespan timeElapsed(now - it->second->getLastActivity());
|
||||
it->second->unlock();
|
||||
if (timeElapsed > timeout) {
|
||||
toRemove.push(it->first);
|
||||
}
|
||||
}
|
||||
//mWorkingMutex.unlock();
|
||||
mWorkingMutex.unlock();
|
||||
|
||||
while (toRemove.size() > 0) {
|
||||
int handle = toRemove.top();
|
||||
toRemove.pop();
|
||||
releaseSession(handle);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void SessionManager::deleteLoginCookies(Poco::Net::HTTPServerRequest& request, Poco::Net::HTTPServerResponse& response, Session* activeSession/* = nullptr*/)
|
||||
@ -505,7 +563,11 @@ void SessionManager::deleteLoginCookies(Poco::Net::HTTPServerRequest& request, P
|
||||
if (activeSession) {
|
||||
try {
|
||||
int session_id = atoi(it->second.data());
|
||||
if (session_id == activeSession->getHandle()) continue;
|
||||
if (activeSession->tryLock()) {
|
||||
bool session_id_is_handle = session_id == activeSession->getHandle();
|
||||
activeSession->unlock();
|
||||
if (session_id_is_handle) continue;
|
||||
}
|
||||
}
|
||||
catch (...) {}
|
||||
}
|
||||
@ -534,6 +596,10 @@ void SessionManager::deleteLoginCookies(Poco::Net::HTTPServerRequest& request, P
|
||||
|
||||
bool SessionManager::checkPwdValidation(const std::string& pwd, NotificationList* errorReciver)
|
||||
{
|
||||
if ((ServerConfig::g_AllowUnsecureFlags & ServerConfig::UNSECURE_ALLOW_ALL_PASSWORDS) == ServerConfig::UNSECURE_ALLOW_ALL_PASSWORDS) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!isValid(pwd, VALIDATE_PASSWORD)) {
|
||||
errorReciver->addError(new Error("Passwort", "Bitte gebe ein gültiges Password ein mit mindestens 8 Zeichen, Groß- und Kleinbuchstaben, mindestens einer Zahl und einem Sonderzeichen (@$!%*?&+-_) ein!"));
|
||||
|
||||
|
||||
@ -88,6 +88,7 @@ protected:
|
||||
// sessions storage
|
||||
std::map<int, Session*> mRequestSessionMap;
|
||||
std::stack<int> mEmptyRequestStack;
|
||||
int mDeadLockedSessionCount;
|
||||
|
||||
bool mInitalized;
|
||||
|
||||
|
||||
@ -212,6 +212,18 @@ std::vector<int> SingletonTaskObserver::getTasksCount(const std::string& email)
|
||||
return taskCounts;
|
||||
}
|
||||
|
||||
int SingletonTaskObserver::getTasksCount(TaskObserverType type)
|
||||
{
|
||||
int type_sum_count = 0;
|
||||
lock("SingletonTaskObserver::getTasksCount");
|
||||
for (int i = 0; i < mObserverEntrys.getNItems(); i++) {
|
||||
UserObserverEntry* entry = static_cast<UserObserverEntry*>(mObserverEntrys.findByIndex(i));
|
||||
type_sum_count += entry->mTasksCount[type];
|
||||
}
|
||||
unlock();
|
||||
return type_sum_count;
|
||||
}
|
||||
|
||||
const char* SingletonTaskObserver::TaskObserverTypeToString(TaskObserverType type)
|
||||
{
|
||||
switch (type) {
|
||||
|
||||
@ -46,6 +46,7 @@ public:
|
||||
int getTaskCount(const std::string& email, TaskObserverType type);
|
||||
int getTaskCount(DHASH id, TaskObserverType type);
|
||||
std::vector<int> getTasksCount(const std::string& email);
|
||||
int getTasksCount(TaskObserverType type);
|
||||
|
||||
static const char* TaskObserverTypeToString(TaskObserverType type);
|
||||
static TaskObserverType StringToTaskObserverType(const std::string& typeString);
|
||||
|
||||
@ -366,7 +366,7 @@ namespace controller {
|
||||
|
||||
int User::checkIfVerificationEmailsShouldBeResend(const Poco::Util::Timer& timer)
|
||||
{
|
||||
|
||||
return 0;
|
||||
auto cm = ConnectionManager::getInstance();
|
||||
auto em = ErrorManager::getInstance();
|
||||
static const char* function_name = "User::checkIfVerificationEmailsShouldBeResend";
|
||||
@ -498,5 +498,4 @@ namespace controller {
|
||||
}
|
||||
return updated_count;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -89,7 +89,6 @@ namespace controller {
|
||||
//! \return -3 password key creation already running
|
||||
//! - create authenticated encryption key from password and email
|
||||
//! - compare hash with in db saved hash
|
||||
|
||||
int login(const std::string& password);
|
||||
|
||||
// ***********************************************************************************
|
||||
|
||||
@ -54,6 +54,7 @@ namespace controller {
|
||||
return mKeyPair;
|
||||
}
|
||||
mKeyPair = createGradidoKeyPair();
|
||||
return mKeyPair;
|
||||
}
|
||||
|
||||
KeyPairEd25519* UserBackup::createGradidoKeyPair()
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
#define DR_LUA_WEB_MODULE_ERROR_ERROR_H
|
||||
|
||||
#include "Notification.h"
|
||||
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
|
||||
|
||||
@ -21,6 +21,8 @@ public:
|
||||
Error(const char* functionName, const char* message);
|
||||
~Error();
|
||||
|
||||
const char* getFunctionName() { return mFunctionName.data(); }
|
||||
const char* getMessage() { return mMessage.data(); }
|
||||
virtual std::string getString(bool withNewline = true) const;
|
||||
virtual std::string getHtmlString() const;
|
||||
|
||||
|
||||
@ -69,9 +69,11 @@ JsonRequestReturn JsonRequest::request(const char* methodName, const Poco::Net::
|
||||
fileName += ".html";
|
||||
|
||||
FILE* f = fopen(fileName.data(), "wt");
|
||||
std::string responseString = responseStringStream.str();
|
||||
fwrite(responseString.data(), 1, responseString.size(), f);
|
||||
fclose(f);
|
||||
if (f) {
|
||||
std::string responseString = responseStringStream.str();
|
||||
fwrite(responseString.data(), 1, responseString.size(), f);
|
||||
fclose(f);
|
||||
}
|
||||
// */
|
||||
sendErrorsAsEmail(responseStringStream.str());
|
||||
return JSON_REQUEST_RETURN_PARSE_ERROR;
|
||||
@ -189,4 +191,4 @@ JsonRequestReturn JsonRequest::requestGRPCRelay(const Poco::Net::NameValueCollec
|
||||
|
||||
|
||||
return JSON_REQUEST_RETURN_OK;
|
||||
}
|
||||
}
|
||||
|
||||
@ -119,6 +119,21 @@ void NotificationList::printErrors()
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::string> NotificationList::getErrorsArray()
|
||||
{
|
||||
std::vector<std::string> result;
|
||||
result.reserve(mErrorStack.size());
|
||||
|
||||
while (mErrorStack.size() > 0) {
|
||||
auto error = mErrorStack.top();
|
||||
mErrorStack.pop();
|
||||
//result->add(error->getString());
|
||||
result.push_back(error->getString());
|
||||
delete error;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string NotificationList::getErrorsHtml()
|
||||
{
|
||||
std::string res;
|
||||
@ -164,7 +179,7 @@ std::string NotificationList::getErrorsHtmlNewFormat()
|
||||
/*
|
||||
<div class="alert alert-error" role="alert">
|
||||
<i class="material-icons-outlined">report_problem</i>
|
||||
<span>Der Empfänger wurde nicht auf dem Login-Server gefunden, hat er sein Konto schon angelegt?</span>
|
||||
<span>Der Empf<EFBFBD>nger wurde nicht auf dem Login-Server gefunden, hat er sein Konto schon angelegt?</span>
|
||||
</div>
|
||||
*/
|
||||
|
||||
@ -197,5 +212,4 @@ void NotificationList::sendErrorsAsEmail(std::string rawHtml/* = ""*/)
|
||||
|
||||
//UniLib::controller::TaskPtr sendErrorMessageTask(new SendErrorMessage(message, ServerConfig::g_CPUScheduler));
|
||||
//sendErrorMessageTask->scheduleTask(sendErrorMessageTask);
|
||||
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
#include "Session.h"
|
||||
#include "Session.h"
|
||||
#include "../lib/Profiler.h"
|
||||
#include "../ServerConfig.h"
|
||||
|
||||
@ -83,6 +83,47 @@ void Session::reset()
|
||||
//printf("[Session::reset] finished\n");
|
||||
}
|
||||
|
||||
int Session::isActive()
|
||||
{
|
||||
int ret = 0;
|
||||
try {
|
||||
mWorkMutex.tryLock(100);
|
||||
}
|
||||
catch (Poco::TimeoutException &ex) {
|
||||
return -1;
|
||||
}
|
||||
ret = (int)mActive;
|
||||
unlock();
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
bool Session::isDeadLocked()
|
||||
{
|
||||
try {
|
||||
mWorkMutex.tryLock(200);
|
||||
unlock();
|
||||
return false;
|
||||
}
|
||||
catch (Poco::Exception& ex) {
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Session::setActive(bool active)
|
||||
{
|
||||
try {
|
||||
mWorkMutex.tryLock(100);
|
||||
}
|
||||
catch (Poco::TimeoutException &ex) {
|
||||
return false;
|
||||
}
|
||||
mActive = active;
|
||||
unlock();
|
||||
return true;
|
||||
}
|
||||
|
||||
void Session::updateTimeout()
|
||||
{
|
||||
lock("Session::updateTimeout");
|
||||
@ -153,6 +194,126 @@ bool Session::adminCreateUser(const std::string& first_name, const std::string&
|
||||
|
||||
return true;
|
||||
}
|
||||
//
|
||||
bool Session::createUser(const std::string& first_name, const std::string& last_name, const std::string& email, const std::string& password)
|
||||
{
|
||||
Profiler usedTime;
|
||||
auto sm = SessionManager::getInstance();
|
||||
if (!sm->isValid(first_name, VALIDATE_NAME)) {
|
||||
addError(new Error(gettext("Vorname"), gettext("Bitte gebe einen Namen an. Mindestens 3 Zeichen, keines folgender Zeichen <>&;")), false);
|
||||
return false;
|
||||
}
|
||||
if (!sm->isValid(last_name, VALIDATE_NAME)) {
|
||||
addError(new Error(gettext("Nachname"), gettext("Bitte gebe einen Namen an. Mindestens 3 Zeichen, keines folgender Zeichen <>&;")), false);
|
||||
return false;
|
||||
}
|
||||
if (!sm->isValid(email, VALIDATE_EMAIL)) {
|
||||
addError(new Error(gettext("E-Mail"), gettext("Bitte gebe eine gültige E-Mail Adresse an.")), false);
|
||||
return false;
|
||||
}
|
||||
if (!sm->checkPwdValidation(password, this)) {
|
||||
return false;
|
||||
}
|
||||
/*if (passphrase.size() > 0 && !sm->isValid(passphrase, VALIDATE_PASSPHRASE)) {
|
||||
addError(new Error("Merkspruch", "Der Merkspruch ist nicht gültig, er besteht aus 24 Wörtern, mit Komma getrennt."));
|
||||
return false;
|
||||
}
|
||||
if (passphrase.size() == 0) {
|
||||
//mPassphrase = User::generateNewPassphrase(&ServerConfig::g_Mnemonic_WordLists[ServerConfig::MNEMONIC_BIP0039_SORTED_ORDER]);
|
||||
mPassphrase = User::generateNewPassphrase(&ServerConfig::g_Mnemonic_WordLists[ServerConfig::MNEMONIC_GRADIDO_BOOK_GERMAN_RANDOM_ORDER]);
|
||||
}
|
||||
else {
|
||||
//mPassphrase = passphrase;
|
||||
}*/
|
||||
|
||||
// check if user with that email already exist
|
||||
|
||||
auto dbConnection = ConnectionManager::getInstance()->getConnection(CONNECTION_MYSQL_LOGIN_SERVER);
|
||||
Poco::Data::Statement select(dbConnection);
|
||||
select << "SELECT email from users where email = ?;", useRef(email);
|
||||
try {
|
||||
if (select.execute() > 0) {
|
||||
addError(new Error(gettext("E-Mail"), gettext("Für diese E-Mail Adresse gibt es bereits einen Account")), false);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Poco::Exception& exc) {
|
||||
printf("mysql exception: %s\n", exc.displayText().data());
|
||||
}
|
||||
|
||||
mSessionUser = new User(email.data(), first_name.data(), last_name.data());
|
||||
mNewUser = controller::User::create(email, first_name, last_name);
|
||||
updateTimeout();
|
||||
|
||||
// Prepare E-Mail
|
||||
//UniLib::controller::TaskPtr prepareEmail(new PrepareEmailTask(ServerConfig::g_CPUScheduler));
|
||||
//prepareEmail->scheduleTask(prepareEmail);
|
||||
|
||||
// create user crypto key
|
||||
UniLib::controller::TaskPtr cryptoKeyTask(new UserCreateCryptoKey(mSessionUser, mNewUser, password, ServerConfig::g_CryptoCPUScheduler));
|
||||
cryptoKeyTask->setFinishCommand(new SessionStateUpdateCommand(SESSION_STATE_CRYPTO_KEY_GENERATED, this));
|
||||
cryptoKeyTask->scheduleTask(cryptoKeyTask);
|
||||
|
||||
// depends on crypto key, write user record into db
|
||||
UniLib::controller::TaskPtr writeUserIntoDB(new UserWriteIntoDB(mSessionUser, ServerConfig::g_CPUScheduler, 1));
|
||||
writeUserIntoDB->setParentTaskPtrInArray(cryptoKeyTask, 0);
|
||||
writeUserIntoDB->setFinishCommand(new SessionStateUpdateCommand(SESSION_STATE_USER_WRITTEN, this));
|
||||
writeUserIntoDB->scheduleTask(writeUserIntoDB);
|
||||
|
||||
std::unique_lock<std::shared_mutex> _lock(mSharedMutex);
|
||||
mEmailVerificationCodeObject = controller::EmailVerificationCode::create(model::table::EMAIL_OPT_IN_REGISTER);
|
||||
UniLib::controller::TaskPtr writeEmailVerification(new WriteEmailVerification(mSessionUser, mEmailVerificationCodeObject, ServerConfig::g_CPUScheduler, 1));
|
||||
|
||||
writeEmailVerification->setParentTaskPtrInArray(writeUserIntoDB, 0);
|
||||
writeEmailVerification->setFinishCommand(new SessionStateUpdateCommand(SESSION_STATE_EMAIL_VERIFICATION_WRITTEN, this));
|
||||
writeEmailVerification->scheduleTask(writeEmailVerification);
|
||||
|
||||
|
||||
/*printf("LastName: %s\n", last_name.data());
|
||||
for (int i = 0; i < last_name.size(); i++) {
|
||||
char c = last_name.data()[i];
|
||||
//printf("%d ", c);
|
||||
}
|
||||
//printf("\n\n");
|
||||
*/
|
||||
|
||||
// depends on writeUser because need user_id, write email verification into db
|
||||
/*auto message = new Poco::Net::MailMessage;
|
||||
Poco::Net::MediaType mt("text", "plain");
|
||||
mt.setParameter("charset", "utf-8");
|
||||
message->setContentType(mt);
|
||||
|
||||
message->addRecipient(Poco::Net::MailRecipient(Poco::Net::MailRecipient::PRIMARY_RECIPIENT, email));
|
||||
message->setSubject(gettext("Gradido: E-Mail Verification"));
|
||||
std::stringstream ss;
|
||||
ss << "Hallo " << first_name << " " << last_name << "," << std::endl << std::endl;
|
||||
ss << "Du oder jemand anderes hat sich soeben mit dieser E-Mail Adresse bei Gradido registriert. " << std::endl;
|
||||
ss << "Wenn du es warst, klicke bitte auf den Link: " << ServerConfig::g_serverPath << "/checkEmail/" << mEmailVerificationCode << std::endl;
|
||||
//ss << "oder kopiere den Code: " << mEmailVerificationCode << " selbst dort hinein." << std::endl;
|
||||
ss << "oder kopiere den obigen Link in Dein Browserfenster." << std::endl;
|
||||
ss << std::endl;
|
||||
ss << "Mit freundlichen " << u8"Grüßen" << std::endl;
|
||||
ss << "Dario, Gradido Server Admin" << std::endl;
|
||||
|
||||
|
||||
message->addContent(new Poco::Net::StringPartSource(ss.str()));
|
||||
*/
|
||||
//UniLib::controller::TaskPtr sendEmail(new SendEmailTask(message, ServerConfig::g_CPUScheduler, 1));
|
||||
//Email(AutoPtr<controller::EmailVerificationCode> emailVerification, AutoPtr<controller::User> user, EmailType type);
|
||||
UniLib::controller::TaskPtr sendEmail(new SendEmailTask(new model::Email(mEmailVerificationCodeObject, mNewUser, model::EMAIL_USER_VERIFICATION_CODE), ServerConfig::g_CPUScheduler, 1));
|
||||
//sendEmail->setParentTaskPtrInArray(prepareEmail, 0);
|
||||
sendEmail->setParentTaskPtrInArray(writeEmailVerification, 0);
|
||||
sendEmail->setFinishCommand(new SessionStateUpdateCommand(SESSION_STATE_EMAIL_VERIFICATION_SEND, this));
|
||||
sendEmail->scheduleTask(sendEmail);
|
||||
|
||||
// write user into db
|
||||
// generate and write email verification into db
|
||||
// send email
|
||||
|
||||
//printf("[Session::createUser] time: %s\n", usedTime.string().data());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Session::createUserDirect(const std::string& first_name, const std::string& last_name, const std::string& email, const std::string& password, int groupId)
|
||||
@ -390,6 +551,7 @@ int Session::comparePassphraseWithSavedKeys(const std::string& inputPassphrase,
|
||||
return -2;
|
||||
}
|
||||
auto passphrase = Passphrase::create(inputPassphrase, wordSource);
|
||||
// if (!keys.generateFromPassphrase(inputPassphrase.data(), wordSource)) {
|
||||
if (passphrase.isNull() || !passphrase->checkIfValid()) {
|
||||
addError(new ParamError(functionName, "invalid passphrase", inputPassphrase));
|
||||
if (!mNewUser.isNull() && mNewUser->getModel()) {
|
||||
@ -426,7 +588,7 @@ int Session::comparePassphraseWithSavedKeys(const std::string& inputPassphrase,
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool Session::startProcessingTransaction(const std::string& proto_message_base64)
|
||||
bool Session::startProcessingTransaction(const std::string& proto_message_base64, bool autoSign/* = false*/)
|
||||
{
|
||||
static const char* funcName = "Session::startProcessingTransaction";
|
||||
lock(funcName);
|
||||
@ -443,9 +605,37 @@ bool Session::startProcessingTransaction(const std::string& proto_message_base64
|
||||
}
|
||||
}
|
||||
|
||||
Poco::AutoPtr<ProcessingTransaction> processorTask(new ProcessingTransaction(proto_message_base64, DRMakeStringHash(mNewUser->getModel()->getEmail().data())));
|
||||
processorTask->scheduleTask(processorTask);
|
||||
mProcessingTransactions.push_back(processorTask);
|
||||
Languages lang = LANG_DE;
|
||||
if (!mNewUser.isNull()) {
|
||||
lang = LanguageManager::languageFromString(mNewUser->getModel()->getLanguageKey());
|
||||
}
|
||||
|
||||
Poco::AutoPtr<ProcessingTransaction> processorTask(
|
||||
new ProcessingTransaction(
|
||||
proto_message_base64,
|
||||
DRMakeStringHash(mSessionUser->getEmail().data()),
|
||||
lang
|
||||
)
|
||||
);
|
||||
if (autoSign && (ServerConfig::g_AllowUnsecureFlags & ServerConfig::UNSECURE_AUTO_SIGN_TRANSACTIONS) == ServerConfig::UNSECURE_AUTO_SIGN_TRANSACTIONS) {
|
||||
if (processorTask->run() != 0) {
|
||||
getErrors(processorTask);
|
||||
unlock();
|
||||
return false;
|
||||
}
|
||||
Poco::AutoPtr<SigningTransaction> signingTransaction(new SigningTransaction(processorTask, mNewUser));
|
||||
//signingTransaction->scheduleTask(signingTransaction);
|
||||
if (signingTransaction->run() != 0) {
|
||||
getErrors(signingTransaction);
|
||||
unlock();
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
processorTask->scheduleTask(processorTask);
|
||||
mProcessingTransactions.push_back(processorTask);
|
||||
}
|
||||
unlock();
|
||||
return true;
|
||||
|
||||
@ -483,23 +673,26 @@ Poco::AutoPtr<ProcessingTransaction> Session::getNextReadyTransaction(size_t* wo
|
||||
return mCurrentActiveProcessingTransaction;
|
||||
}
|
||||
|
||||
void Session::finalizeTransaction(bool sign, bool reject)
|
||||
bool Session::finalizeTransaction(bool sign, bool reject)
|
||||
{
|
||||
int result = -1;
|
||||
lock("Session::finalizeTransaction");
|
||||
if (mCurrentActiveProcessingTransaction.isNull()) {
|
||||
unlock();
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
mProcessingTransactions.remove(mCurrentActiveProcessingTransaction);
|
||||
|
||||
if (!reject) {
|
||||
if (sign) {
|
||||
Poco::AutoPtr<SigningTransaction> signingTransaction(new SigningTransaction(mCurrentActiveProcessingTransaction, mNewUser));
|
||||
signingTransaction->scheduleTask(signingTransaction);
|
||||
//signingTransaction->scheduleTask(signingTransaction);
|
||||
result = signingTransaction->run();
|
||||
}
|
||||
}
|
||||
mCurrentActiveProcessingTransaction.assign(nullptr);
|
||||
unlock();
|
||||
return result == 0;
|
||||
}
|
||||
|
||||
size_t Session::getProcessingTransactionCount()
|
||||
@ -536,37 +729,74 @@ UserState Session::loadUser(const std::string& email, const std::string& passwor
|
||||
}
|
||||
}
|
||||
//Profiler usedTime;
|
||||
lock(functionName);
|
||||
//printf("before lock\n");
|
||||
//lock(functionName);
|
||||
Poco::ScopedLock<Poco::Mutex> _lock(mWorkMutex);
|
||||
|
||||
//if (!mSessionUser) {
|
||||
if (mNewUser.isNull()) {
|
||||
//printf("new user is null\n");
|
||||
mNewUser = controller::User::create();
|
||||
|
||||
//printf("new user created\n");
|
||||
// load user for email only once from db
|
||||
mNewUser->load(email);
|
||||
|
||||
//printf("load new user from db with email: %s\n", email.data());
|
||||
mSessionUser = new User(mNewUser);
|
||||
//mSessionUser = new User(email.data());
|
||||
|
||||
//printf("user loaded from email\n");
|
||||
}
|
||||
//printf("before get model\n");
|
||||
auto user_model = mNewUser->getModel();
|
||||
if (user_model && user_model->isDisabled()) {
|
||||
if (user_model && user_model->isDisabled()) {
|
||||
return USER_DISABLED;
|
||||
}
|
||||
if (mNewUser->getUserState() >= USER_LOADED_FROM_DB) {
|
||||
int loginResult = mNewUser->login(password);
|
||||
int exitCount = 0;
|
||||
if (loginResult == -3)
|
||||
{
|
||||
do
|
||||
{
|
||||
Poco::Thread::sleep(100);
|
||||
loginResult = mNewUser->login(password);
|
||||
exitCount++;
|
||||
} while (-3 == loginResult && exitCount < 15);
|
||||
if (exitCount > 1)
|
||||
{
|
||||
addError(new ParamError(functionName, "login succeed, retrys: ", exitCount));
|
||||
addError(new ParamError(functionName, "email: ", email));
|
||||
sendErrorsAsEmail();
|
||||
}
|
||||
|
||||
if (exitCount >= 15)
|
||||
{
|
||||
auto running_password_creations = observer->getTasksCount(TASK_OBSERVER_PASSWORD_CREATION);
|
||||
|
||||
addError(new ParamError(functionName, "login failed after 15 retrys and 100 ms sleep between, currently running passwort creation tasks: ", running_password_creations));
|
||||
addError(new ParamError(functionName, "email: ", email));
|
||||
sendErrorsAsEmail();
|
||||
return USER_PASSWORD_ENCRYPTION_IN_PROCESS;
|
||||
}
|
||||
}
|
||||
|
||||
if (-1 == loginResult) {
|
||||
if (-1 == loginResult)
|
||||
{
|
||||
addError(new Error(functionName, "error in user data set, saved pubkey didn't match extracted pubkey from private key"));
|
||||
addError(new ParamError(functionName, "user email", mNewUser->getModel()->getEmail()));
|
||||
sendErrorsAsEmail();
|
||||
//unlock();
|
||||
//return USER_KEYS_DONT_MATCH;
|
||||
}
|
||||
if (0 == loginResult) {
|
||||
unlock();
|
||||
if (0 == loginResult)
|
||||
{
|
||||
return USER_PASSWORD_INCORRECT;
|
||||
}
|
||||
// error decrypting private key
|
||||
if (-2 == loginResult) {
|
||||
if (-2 == loginResult)
|
||||
{
|
||||
// check if we have access to the passphrase, if so we can reencrypt the private key
|
||||
printf("try reencrypting key\n");
|
||||
auto user_model = mNewUser->getModel();
|
||||
auto user_backups = controller::UserBackup::load(user_model->getID());
|
||||
for (auto it = user_backups.begin(); it != user_backups.end(); it++) {
|
||||
@ -790,7 +1020,8 @@ Poco::Net::HTTPCookie Session::getLoginCookie()
|
||||
{
|
||||
auto keks = Poco::Net::HTTPCookie("GRADIDO_LOGIN", std::to_string(mHandleId));
|
||||
// prevent reading or changing cookie with js
|
||||
keks.setHttpOnly();
|
||||
// keks.setHttpOnly();
|
||||
|
||||
keks.setPath("/");
|
||||
// send cookie only via https, on linux, except in test builds
|
||||
#ifndef WIN32
|
||||
|
||||
@ -151,18 +151,24 @@ public:
|
||||
return mEmailVerificationCodeObject->getModel()->getType();
|
||||
}
|
||||
|
||||
inline bool isActive() { bool bret = false; lock("Session::isActive"); bret = mActive; unlock(); return bret; }
|
||||
inline void setActive(bool active) { lock("Sessions::setActive"); mActive = active; unlock(); }
|
||||
//! \return -1 if session is locked
|
||||
//! \return 1 if session is active
|
||||
//! \return 0
|
||||
int isActive();
|
||||
//! \return false if session is locked
|
||||
bool setActive(bool active);
|
||||
|
||||
bool isDeadLocked();
|
||||
|
||||
inline Poco::DateTime getLastActivity() { return mLastActivity; }
|
||||
|
||||
// ------------------------ transactions functions ----------------------------
|
||||
|
||||
//! \return true if succeed
|
||||
bool startProcessingTransaction(const std::string& proto_message_base64);
|
||||
bool startProcessingTransaction(const std::string& proto_message_base64, bool autoSign = false);
|
||||
//! \param working if set will filled with transaction running
|
||||
Poco::AutoPtr<ProcessingTransaction> getNextReadyTransaction(size_t* working = nullptr);
|
||||
void finalizeTransaction(bool sign, bool reject);
|
||||
bool finalizeTransaction(bool sign, bool reject);
|
||||
size_t getProcessingTransactionCount();
|
||||
|
||||
inline LanguageCatalog* getLanguageCatalog() { return mLanguageCatalog.isNull() ? nullptr : mLanguageCatalog; }
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
#include "Poco/DateTimeFormatter.h"
|
||||
#include <sodium.h>
|
||||
|
||||
//TransactionCreation::TransactionCreation(const std::string& memo, const model::messages::gradido::TransactionCreation& protoCreation)
|
||||
TransactionCreation::TransactionCreation(const std::string& memo, const proto::gradido::GradidoCreation& protoCreation)
|
||||
: TransactionBase(memo), mProtoCreation(protoCreation)
|
||||
{
|
||||
@ -22,7 +23,16 @@ int TransactionCreation::prepare()
|
||||
}
|
||||
auto receiver_amount = mProtoCreation.receiver();
|
||||
|
||||
auto receiverPublic = receiver_amount.pubkey();
|
||||
if (receiverAmount.amount() <= 0) {
|
||||
addError(new Error(functionName, "amount must be > 0"));
|
||||
return -4;
|
||||
}
|
||||
if (receiverAmount.amount() > 10000000) {
|
||||
addError(new Error(functionName, "amount must be <= 1000 GDD"));
|
||||
return -5;
|
||||
}
|
||||
|
||||
auto receiverPublic = receiverAmount.ed25519_receiver_pubkey();
|
||||
if (receiverPublic.size() != 32) {
|
||||
addError(new Error(functionName, "receiver public invalid (size not 32)"));
|
||||
return -2;
|
||||
|
||||
@ -46,6 +46,7 @@ void TransactionTransfer::KontoTableEntry::composeAmountCellString(google::proto
|
||||
|
||||
// ********************************************************************************************************************************
|
||||
|
||||
//TransactionTransfer::TransactionTransfer(const std::string& memo, const model::messages::gradido::Transfer& protoTransfer)
|
||||
TransactionTransfer::TransactionTransfer(const std::string& memo, const proto::gradido::GradidoTransfer& protoTransfer)
|
||||
: TransactionBase(memo), mProtoTransfer(protoTransfer)
|
||||
{
|
||||
@ -69,6 +70,7 @@ int TransactionTransfer::prepare()
|
||||
|
||||
char pubkeyHexTemp[65];
|
||||
|
||||
/*
|
||||
if (mProtoTransfer.has_local())
|
||||
{
|
||||
auto local_transfer = mProtoTransfer.local();
|
||||
@ -94,8 +96,45 @@ int TransactionTransfer::prepare()
|
||||
else {
|
||||
mKontoTable.push_back(KontoTableEntry(sender_user->getModel(), amount, true));
|
||||
}
|
||||
}
|
||||
// TODO: add version for group transfer
|
||||
}
|
||||
*/
|
||||
for (int i = 0; i < mProtoTransfer.senderamounts_size(); i++) {
|
||||
auto senderAmount = mProtoTransfer.senderamounts(i);
|
||||
auto pubkey = senderAmount.ed25519_sender_pubkey();
|
||||
senderSum += senderAmount.amount();
|
||||
if (pubkey.size() != 32) {
|
||||
addError(new ParamError(functionName, "invalid public key for sender ", i));
|
||||
unlock();
|
||||
return -3;
|
||||
}
|
||||
//User user((const unsigned char*)pubkey.data());
|
||||
auto user = controller::User::create();
|
||||
if (!user->load((const unsigned char*)pubkey.data())) {
|
||||
sodium_bin2hex(pubkeyHexTemp, 65, (const unsigned char*)pubkey.data(), pubkey.size());
|
||||
mKontoTable.push_back(KontoTableEntry(pubkeyHexTemp, senderAmount.amount(), true));
|
||||
}
|
||||
else {
|
||||
mKontoTable.push_back(KontoTableEntry(sender_user->getModel(), -amount, true));
|
||||
}
|
||||
|
||||
if (!receiver_user->load((const unsigned char*)receiver_pubkey.data())) {
|
||||
sodium_bin2hex(pubkeyHexTemp, 65, (const unsigned char*)receiver_pubkey.data(), receiver_pubkey.size());
|
||||
mKontoTable.push_back(KontoTableEntry(pubkeyHexTemp, amount, true));
|
||||
}
|
||||
else {
|
||||
mKontoTable.push_back(KontoTableEntry(sender_user->getModel(), amount, true));
|
||||
}
|
||||
}
|
||||
if (senderSum != receiverSum) {
|
||||
addError(new Error(functionName, "sender amounts sum != receiver amounts sum"));
|
||||
unlock();
|
||||
return -5;
|
||||
}
|
||||
if (senderSum < 0) {
|
||||
addError(new Error(functionName, "negative amount not supported"));
|
||||
unlock();
|
||||
return -6;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
@ -139,4 +178,3 @@ const std::string& TransactionTransfer::getAmountCell(int index)
|
||||
|
||||
return mKontoTable[index].amountCell;
|
||||
}
|
||||
|
||||
|
||||
@ -88,7 +88,8 @@ namespace model {
|
||||
{
|
||||
auto cm = ConnectionManager::getInstance();
|
||||
Poco::ScopedLock<Poco::Mutex> _lock(mWorkMutex);
|
||||
Poco::Data::Statement select = _loadFromDB(cm->getConnection(CONNECTION_MYSQL_LOGIN_SERVER), fieldName);
|
||||
auto session = cm->getConnection(CONNECTION_MYSQL_LOGIN_SERVER);
|
||||
Poco::Data::Statement select = _loadFromDB(session, fieldName);
|
||||
select, Poco::Data::Keywords::useRef(fieldValue);
|
||||
|
||||
size_t resultCount = 0;
|
||||
@ -139,7 +140,8 @@ namespace model {
|
||||
results.reserve(expectedResults);
|
||||
}
|
||||
auto cm = ConnectionManager::getInstance();
|
||||
Poco::Data::Statement select = _loadMultipleFromDB(cm->getConnection(CONNECTION_MYSQL_LOGIN_SERVER), fieldName);
|
||||
auto session = cm->getConnection(CONNECTION_MYSQL_LOGIN_SERVER);
|
||||
Poco::Data::Statement select = _loadMultipleFromDB(session, fieldName);
|
||||
select, Poco::Data::Keywords::into(results), Poco::Data::Keywords::useRef(fieldValue);
|
||||
|
||||
size_t resultCount = 0;
|
||||
@ -197,7 +199,8 @@ namespace model {
|
||||
results.reserve(expectedResults);
|
||||
}
|
||||
auto cm = ConnectionManager::getInstance();
|
||||
Poco::Data::Statement select = _loadMultipleFromDB(cm->getConnection(CONNECTION_MYSQL_LOGIN_SERVER), fieldNames, conditionType);
|
||||
auto session = cm->getConnection(CONNECTION_MYSQL_LOGIN_SERVER);
|
||||
Poco::Data::Statement select = _loadMultipleFromDB(session, fieldNames, conditionType);
|
||||
select, Poco::Data::Keywords::into(results);// Poco::Data::Keywords::useRef(fieldValue);
|
||||
for (auto it = fieldValues.begin(); it != fieldValues.end(); it++) {
|
||||
select, Poco::Data::Keywords::useRef(*it);
|
||||
@ -223,7 +226,8 @@ namespace model {
|
||||
{
|
||||
auto cm = ConnectionManager::getInstance();
|
||||
Poco::ScopedLock<Poco::Mutex> _lock(mWorkMutex);
|
||||
Poco::Data::Statement select = _loadFromDB(cm->getConnection(CONNECTION_MYSQL_LOGIN_SERVER), fieldNames, conditionType);
|
||||
auto session = cm->getConnection(CONNECTION_MYSQL_LOGIN_SERVER);
|
||||
Poco::Data::Statement select = _loadFromDB(session, fieldNames, conditionType);
|
||||
select, Poco::Data::Keywords::useRef(field1Value), Poco::Data::Keywords::useRef(field2Value);
|
||||
|
||||
size_t resultCount = 0;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
#include "ProcessingTransaction.h"
|
||||
#include "ProcessingTransaction.h"
|
||||
#include <sodium.h>
|
||||
|
||||
#include "../model/TransactionCreation.h"
|
||||
@ -6,8 +6,12 @@
|
||||
|
||||
#include "../SingletonManager/SingletonTaskObserver.h"
|
||||
|
||||
ProcessingTransaction::ProcessingTransaction(const std::string& proto_message_base64, DHASH userEmailHash)
|
||||
: mType(TRANSACTION_NONE), mProtoMessageBase64(proto_message_base64), mTransactionSpecific(nullptr), mUserEmailHash(userEmailHash)
|
||||
#include "../lib/DataTypeConverter.h"
|
||||
#include "../lib/JsonRequest.h"
|
||||
|
||||
ProcessingTransaction::ProcessingTransaction(const std::string& proto_message_base64, DHASH userEmailHash, Languages lang, Poco::DateTime transactionCreated/* = Poco::DateTime()*/)
|
||||
: mType(TRANSACTION_NONE), mProtoMessageBase64(proto_message_base64), mTransactionSpecific(nullptr), mUserEmailHash(userEmailHash),
|
||||
mLang(lang), mTransactionCreated(transactionCreated)
|
||||
{
|
||||
mHashMutex.lock();
|
||||
mHash = calculateHash(proto_message_base64);
|
||||
@ -39,6 +43,37 @@ HASH ProcessingTransaction::calculateHash(const std::string& proto_message_base6
|
||||
return DRMakeStringHash(proto_message_base64.data(), proto_message_base64.size());
|
||||
}
|
||||
|
||||
std::string ProcessingTransaction::calculateGenericHash(const std::string& protoMessageBase64)
|
||||
{
|
||||
auto mm = MemoryManager::getInstance();
|
||||
auto hash = mm->getFreeMemory(crypto_generichash_BYTES);
|
||||
|
||||
crypto_generichash(*hash, sizeof(DHASH), (const unsigned char*)protoMessageBase64.data(), protoMessageBase64.size(), NULL, 0);
|
||||
std::string base64HashString = DataTypeConverter::binToBase64(hash);
|
||||
mm->releaseMemory(hash);
|
||||
return base64HashString;
|
||||
}
|
||||
|
||||
|
||||
void ProcessingTransaction::reportErrorToCommunityServer(std::string error, std::string errorDetails, std::string created)
|
||||
{
|
||||
auto transaction_hash = calculateGenericHash(mProtoMessageBase64);
|
||||
JsonRequest phpServerRequest(ServerConfig::g_php_serverHost, ServerConfig::g_phpServerPort);
|
||||
Poco::Net::NameValueCollection payload;
|
||||
|
||||
payload.set("created", created);
|
||||
payload.set("transactionGenericHash", transaction_hash);
|
||||
payload.set("error", error);
|
||||
payload.set("errorMessage", errorDetails);
|
||||
|
||||
auto ret = phpServerRequest.request("errorInTransaction", payload);
|
||||
if (ret == JSON_REQUEST_RETURN_ERROR) {
|
||||
addError(new Error("ProcessingTransaction::reportErrorToCommunityServer", "php server error"));
|
||||
getErrors(&phpServerRequest);
|
||||
sendErrorsAsEmail();
|
||||
}
|
||||
}
|
||||
|
||||
int ProcessingTransaction::run()
|
||||
{
|
||||
lock();
|
||||
@ -46,6 +81,9 @@ int ProcessingTransaction::run()
|
||||
unsigned char* binBuffer = (unsigned char*)malloc(mProtoMessageBase64.size());
|
||||
size_t resultingBinSize = 0;
|
||||
size_t base64_size = mProtoMessageBase64.size();
|
||||
auto langM = LanguageManager::getInstance();
|
||||
auto catalog = langM->getFreeCatalog(mLang);
|
||||
|
||||
if (sodium_base642bin(
|
||||
binBuffer, base64_size,
|
||||
mProtoMessageBase64.data(), base64_size,
|
||||
@ -54,6 +92,7 @@ int ProcessingTransaction::run()
|
||||
{
|
||||
free(binBuffer);
|
||||
addError(new Error("ProcessingTransaction", "error decoding base64"));
|
||||
reportErrorToCommunityServer(catalog->gettext("decoding error"), catalog->gettext("Error decoding base64 string"), "-1");
|
||||
unlock();
|
||||
return -1;
|
||||
}
|
||||
@ -61,6 +100,7 @@ int ProcessingTransaction::run()
|
||||
free(binBuffer);
|
||||
if (!mTransactionBody.ParseFromString(binString)) {
|
||||
addError(new Error("ProcessingTransaction", "error creating Transaction from binary Message"));
|
||||
reportErrorToCommunityServer(catalog->gettext("decoding error"), catalog->gettext("Error by parsing to protobuf message"), "-1");
|
||||
unlock();
|
||||
return -2;
|
||||
}
|
||||
@ -78,6 +118,7 @@ int ProcessingTransaction::run()
|
||||
if (mTransactionSpecific->prepare()) {
|
||||
getErrors(mTransactionSpecific);
|
||||
addError(new Error("ProcessingTransaction", "error preparing"));
|
||||
reportErrorToCommunityServer(catalog->gettext("format error"), catalog->gettext("format of specific transaction not known, wrong proto version?"), Poco::DateTimeFormatter::format(mTransactionCreated, "%s"));
|
||||
unlock();
|
||||
return -3;
|
||||
}
|
||||
|
||||
@ -9,6 +9,8 @@
|
||||
|
||||
#include "../proto/gradido/TransactionBody.pb.h"
|
||||
|
||||
#include "../SingletonManager/LanguageManager.h"
|
||||
|
||||
/*
|
||||
* @author: Dario Rekowski
|
||||
*
|
||||
@ -30,7 +32,8 @@ class ProcessingTransaction : public UniLib::controller::CPUTask, public Notific
|
||||
{
|
||||
friend SigningTransaction;
|
||||
public:
|
||||
ProcessingTransaction(const std::string& proto_message_base64, DHASH userEmailHash);
|
||||
//! \param lang for error messages in user language
|
||||
ProcessingTransaction(const std::string& proto_message_base64, DHASH userEmailHash, Languages lang, Poco::DateTime transactionCreated = Poco::DateTime());
|
||||
virtual ~ProcessingTransaction();
|
||||
|
||||
int run();
|
||||
@ -48,11 +51,15 @@ public:
|
||||
TransactionTransfer* getTransferTransaction();
|
||||
|
||||
static HASH calculateHash(const std::string& proto_message_base64);
|
||||
static std::string calculateGenericHash(const std::string& protoMessageBase64);
|
||||
inline HASH getHash() { mHashMutex.lock(); HASH hs = mHash; mHashMutex.unlock(); return hs; }
|
||||
|
||||
std::string getBodyBytes();
|
||||
|
||||
protected:
|
||||
|
||||
void reportErrorToCommunityServer(std::string error, std::string errorDetails, std::string created);
|
||||
|
||||
TransactionType mType;
|
||||
std::string mProtoMessageBase64;
|
||||
|
||||
@ -61,8 +68,9 @@ protected:
|
||||
|
||||
HASH mHash;
|
||||
DHASH mUserEmailHash;
|
||||
|
||||
Languages mLang;
|
||||
Poco::Mutex mHashMutex;
|
||||
Poco::DateTime mTransactionCreated;
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
@ -27,8 +27,11 @@
|
||||
#include "../model/hedera/TransactionBody.h"
|
||||
#include "../model/hedera/Transaction.h"
|
||||
|
||||
SigningTransaction::SigningTransaction(Poco::AutoPtr<ProcessingTransaction> processingeTransaction, Poco::AutoPtr<controller::User> newUser)
|
||||
: mProcessingeTransaction(processingeTransaction), mNewUser(newUser)
|
||||
SigningTransaction::SigningTransaction(
|
||||
Poco::AutoPtr<ProcessingTransaction> processingeTransaction,
|
||||
Poco::AutoPtr<controller::User> newUser,
|
||||
bool sendErrorsToAdmin/* = true*/)
|
||||
: mProcessingeTransaction(processingeTransaction), mNewUser(newUser), mSendErrorsToAdminEmail(sendErrorsToAdmin)
|
||||
{
|
||||
auto ob = SingletonTaskObserver::getInstance();
|
||||
auto email = getUserEmail();
|
||||
@ -71,7 +74,7 @@ int SigningTransaction::run() {
|
||||
//if (mUser.isNull() || !mUser->hasCryptoKey()) {
|
||||
if(mNewUser.isNull() || !mNewUser->hasPassword()) {
|
||||
addError(new Error("SigningTransaction", "user hasn't crypto key or is null"));
|
||||
sendErrorsAsEmail();
|
||||
if(mSendErrorsToAdminEmail) sendErrorsAsEmail();
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -89,7 +92,7 @@ int SigningTransaction::run() {
|
||||
}
|
||||
else {
|
||||
addError(new Error("SigningTransaction", "user cannot decrypt private key"));
|
||||
sendErrorsAsEmail();
|
||||
if (mSendErrorsToAdminEmail) sendErrorsAsEmail();
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
@ -99,7 +102,7 @@ int SigningTransaction::run() {
|
||||
*bodyBytes = mProcessingeTransaction->getBodyBytes();
|
||||
if (*bodyBytes == "") {
|
||||
getErrors(mProcessingeTransaction);
|
||||
sendErrorsAsEmail();
|
||||
if (mSendErrorsToAdminEmail) sendErrorsAsEmail();
|
||||
return -3;
|
||||
}
|
||||
// sign
|
||||
@ -113,7 +116,7 @@ int SigningTransaction::run() {
|
||||
}
|
||||
if (!sign) {
|
||||
ErrorManager::getInstance()->sendErrorsAsEmail();
|
||||
sendErrorsAsEmail();
|
||||
if (mSendErrorsToAdminEmail) sendErrorsAsEmail();
|
||||
mm->releaseMemory(sign);
|
||||
return -4;
|
||||
}
|
||||
@ -155,7 +158,7 @@ int SigningTransaction::run() {
|
||||
std::string finalTransactionBin = transaction.SerializeAsString();
|
||||
if (finalTransactionBin == "") {
|
||||
addError(new Error("SigningTransaction", "error serializing final transaction"));
|
||||
sendErrorsAsEmail();
|
||||
if (mSendErrorsToAdminEmail) sendErrorsAsEmail();
|
||||
return -6;
|
||||
}
|
||||
|
||||
@ -200,7 +203,7 @@ int SigningTransaction::run() {
|
||||
auto finalBase64Bin = mm->getFreeMemory(finalBase64Size);
|
||||
if (!sodium_bin2base64(*finalBase64Bin, finalBase64Size, (const unsigned char*)finalTransactionBin.data(), finalTransactionBin.size(), sodium_base64_VARIANT_URLSAFE_NO_PADDING)) {
|
||||
addError(new Error("SigningTransaction", "error convert final transaction to base64"));
|
||||
sendErrorsAsEmail();
|
||||
if (mSendErrorsToAdminEmail) sendErrorsAsEmail();
|
||||
mm->releaseMemory(finalBase64Bin);
|
||||
return -7;
|
||||
}
|
||||
@ -221,18 +224,23 @@ int SigningTransaction::run() {
|
||||
// 443 = HTTPS Default
|
||||
// or http via port 80 if it is a test server
|
||||
// TODO: adding port into ServerConfig
|
||||
bool choose_ssl = false;
|
||||
try {
|
||||
Profiler phpRequestTime;
|
||||
Poco::Net::HTTPClientSession* clientSession = nullptr;
|
||||
|
||||
if (ServerConfig::g_phpServerPort) {
|
||||
clientSession = new Poco::Net::HTTPSClientSession(ServerConfig::g_php_serverHost, ServerConfig::g_phpServerPort);
|
||||
choose_ssl = true;
|
||||
}
|
||||
else if (ServerConfig::SERVER_TYPE_PRODUCTION == ServerConfig::g_ServerSetupType ||
|
||||
ServerConfig::SERVER_TYPE_STAGING == ServerConfig::g_ServerSetupType) {
|
||||
clientSession = new Poco::Net::HTTPSClientSession(ServerConfig::g_php_serverHost, 443);
|
||||
choose_ssl = true;
|
||||
}
|
||||
else {
|
||||
clientSession = new Poco::Net::HTTPClientSession(ServerConfig::g_php_serverHost, 80);
|
||||
choose_ssl = false;
|
||||
}
|
||||
Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_POST, "/JsonRequestHandler");
|
||||
|
||||
@ -263,28 +271,37 @@ int SigningTransaction::run() {
|
||||
addError(new ParamError("SigningTransaction", "error parsing request answer", ex.displayText().data()));
|
||||
|
||||
FILE* f = fopen("response.html", "wt");
|
||||
std::string responseString = responseStringStream.str();
|
||||
fwrite(responseString.data(), 1, responseString.size(), f);
|
||||
fclose(f);
|
||||
if (f) {
|
||||
std::string responseString = responseStringStream.str();
|
||||
fwrite(responseString.data(), 1, responseString.size(), f);
|
||||
fclose(f);
|
||||
}
|
||||
// */
|
||||
sendErrorsAsEmail(responseStringStream.str());
|
||||
if (mSendErrorsToAdminEmail) sendErrorsAsEmail(responseStringStream.str());
|
||||
return -9;
|
||||
}
|
||||
|
||||
//sendErrorsAsEmail("<html><head><title>Hallo</title></head><body><font color='red'>Rote Test </font></body>");
|
||||
|
||||
Poco::JSON::Object object = *parsedJson.extract<Poco::JSON::Object::Ptr>();
|
||||
auto state = object.get("state");
|
||||
std::string stateString = state.convert<std::string>();
|
||||
if (stateString == "error") {
|
||||
addError(new Error("SigningTransaction", "php server return error"));
|
||||
|
||||
std::string stateString = "";
|
||||
if (!object.isNull("state")) {
|
||||
auto state = object.get("state");
|
||||
stateString = state.convert<std::string>();
|
||||
}
|
||||
if (stateString != "success") {
|
||||
addError(new Error("SigningTransaction", "php server don't return success"));
|
||||
if (!object.isNull("msg")) {
|
||||
addError(new ParamError("SigningTransaction", "msg:", object.get("msg").convert<std::string>().data()));
|
||||
}
|
||||
if (!object.isNull("details")) {
|
||||
addError(new ParamError("SigningTransaction", "details:", object.get("details").convert<std::string>().data()));
|
||||
}
|
||||
sendErrorsAsEmail();
|
||||
if (!object.isNull("user_error")) {
|
||||
addError(new ParamError("SigningTransaction", "user_error", object.get("user_error").convert<std::string>().data()));
|
||||
}
|
||||
if (mSendErrorsToAdminEmail) sendErrorsAsEmail();
|
||||
return -10;
|
||||
}
|
||||
delete clientSession;
|
||||
@ -293,8 +310,9 @@ int SigningTransaction::run() {
|
||||
}
|
||||
catch (Poco::Exception& e) {
|
||||
addError(new ParamError("SigningTransaction", "connect error to php server", e.displayText().data()));
|
||||
printf("url: %s\n", ServerConfig::g_php_serverHost.data());
|
||||
sendErrorsAsEmail();
|
||||
addError(new ParamError("SigningTransaction", "url", ServerConfig::g_php_serverHost.data()));
|
||||
addError(new ParamError("SigningTransaction", "choose_ssl", choose_ssl));
|
||||
if (mSendErrorsToAdminEmail) sendErrorsAsEmail(););
|
||||
return -8;
|
||||
}
|
||||
|
||||
|
||||
@ -33,6 +33,7 @@ public:
|
||||
protected:
|
||||
Poco::AutoPtr<ProcessingTransaction> mProcessingeTransaction;
|
||||
Poco::AutoPtr<controller::User> mNewUser;
|
||||
bool mSendErrorsToAdminEmail;
|
||||
|
||||
private:
|
||||
|
||||
@ -40,5 +41,4 @@ private:
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif //GRADIDO_LOGIN_SERVER_TASKS_SIGNING_TRANSACTION_INCLUDE
|
||||
2
src/cpsp/.gitignore
vendored
Normal file
2
src/cpsp/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
/compile.sh
|
||||
/*.dll
|
||||
@ -38,11 +38,16 @@ enum PageState {
|
||||
hasErrors = true;
|
||||
}
|
||||
|
||||
bool transaction_finalize_run = false;
|
||||
bool transaction_finalize_result = false;
|
||||
|
||||
if(!form.empty()) {
|
||||
auto ok = form.get("ok", "");
|
||||
auto abort = form.get("abort", "");
|
||||
auto back = form.get("back", "");
|
||||
if(abort != "") {
|
||||
mSession->finalizeTransaction(false, true);
|
||||
transaction_finalize_result = mSession->finalizeTransaction(false, true);
|
||||
transaction_finalize_run = true;
|
||||
} else if(ok != "") {
|
||||
if(!account_user->hasPassword()) {
|
||||
auto pwd = form.get("sign-password", "");
|
||||
@ -65,15 +70,26 @@ enum PageState {
|
||||
}
|
||||
}
|
||||
if(!hasErrors) {
|
||||
mSession->finalizeTransaction(true, false);
|
||||
transaction_finalize_result = mSession->finalizeTransaction(true, false);
|
||||
transaction_finalize_run = true;
|
||||
}
|
||||
} else if(back == "back") {
|
||||
auto lastExternReferer = mSession->getLastReferer();
|
||||
//lastExternReferer = "";
|
||||
if(lastExternReferer != "" && lastExternReferer.find("transaction-send-coins") == std::string::npos) {
|
||||
//printf("last extern referer: %s\n", lastExternReferer.data());
|
||||
response.redirect(lastExternReferer);
|
||||
} else {
|
||||
response.redirect(ServerConfig::g_php_serverPath + "state-balances/overview");
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
size_t notReadyTransactions = 0;
|
||||
size_t sumTransactions = mSession->getProcessingTransactionCount();
|
||||
if(sumTransactions == 0) {
|
||||
if(sumTransactions == 0 && !transaction_finalize_run) {
|
||||
/*auto observer = SingletonTaskObserver::getInstance();
|
||||
auto emailHash = DRMakeStringHash(mSession->getUser()->getEmail());
|
||||
int breakCount = 0;
|
||||
@ -107,6 +123,19 @@ enum PageState {
|
||||
|
||||
|
||||
%><%@ include file="header_navi_chr.cpsp" %>
|
||||
<% if(transaction_finalize_run) { %>
|
||||
<div class="col-md-10 equel-grid mb-3">
|
||||
<div class="flash-messages" style="background-color: rgba(240,240,240,0.8);" onclick="this.classList.add('hidden')">
|
||||
<ul class='grd-no-style'>
|
||||
<% if(transaction_finalize_result) { %>
|
||||
<li class='grd-success'>Transaktion erfolgreich</li>
|
||||
<% } else { %>
|
||||
<li class='grd-error'>Transaktion fehlgeschlagen</li>
|
||||
<% } %>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<% } %>
|
||||
<div class="col-md-10 equel-grid mb-3">
|
||||
<small class="text-gray d-block mt-3">
|
||||
<% if(sumTransactions > 0 && sumTransactions - notReadyTransactions != 1) { %>
|
||||
@ -210,6 +239,12 @@ enum PageState {
|
||||
<i class="material-icons-outlined">delete</i>
|
||||
<%= gettext("Transaktion verwerfen") %>
|
||||
</button>
|
||||
<% if(sumTransactions == 0) { %>
|
||||
<button type="submit" class="form-button button-cancel" name="back" value="back">
|
||||
<i class="material-icons-outlined">back</i>
|
||||
Zurück
|
||||
</button>
|
||||
<% } %>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -9,6 +9,7 @@
|
||||
#include "../proto/gradido/TransactionBody.pb.h"
|
||||
#include "../controller/User.h"
|
||||
#include "../model/TransactionBase.h"
|
||||
#include "../model/TransactionCreation.h"
|
||||
%>
|
||||
<%%
|
||||
const char* pageName = "Decode Transaction";
|
||||
@ -100,6 +101,7 @@
|
||||
|
||||
<% } else if(transactionBody.has_creation()) {
|
||||
auto creation = transactionBody.creation();
|
||||
TransactionCreation creationObject("", creation);
|
||||
auto receiver = creation.receiver();
|
||||
char hex[65]; memset(hex, 0, 65);
|
||||
sodium_bin2hex(hex, 65, (const unsigned char*)receiver.pubkey().data(), receiver.pubkey().size());
|
||||
@ -121,6 +123,7 @@
|
||||
<p><%= user->getModel()->toHTMLString() %></p>
|
||||
<% } %>
|
||||
<p>amount: <%= TransactionBase::amountToString(receiver.amount()) %> GDD</p>
|
||||
<p>target date: <%= creationObject.getTargetDateString() %></p>
|
||||
<% } %>
|
||||
<% } %>
|
||||
</div>
|
||||
|
||||
@ -64,25 +64,38 @@
|
||||
// get language
|
||||
// first check url, second check language header
|
||||
// for debugging client ip
|
||||
auto client_ip = request.clientAddress();
|
||||
auto client_host = request.clientAddress().host();
|
||||
//auto client_ip = request.clientAddress();
|
||||
// X-Real-IP forwarded ip from nginx config
|
||||
auto client_host_string = request.get("X-Real-IP", client_host.toString());
|
||||
std::string clientIpString = "client ip: ";
|
||||
client_host = Poco::Net::IPAddress(client_host_string);
|
||||
clientIpString += client_ip.toString();
|
||||
// clientIpString += client_host_string;
|
||||
Poco::Logger::get("requestLog").information(clientIpString);
|
||||
// debugging end
|
||||
auto user_host = request.clientAddress().host();
|
||||
mSession->setClientIp(user_host);
|
||||
// mSession->setClientIp(client_host);
|
||||
response.addCookie(mSession->getLoginCookie());
|
||||
} else {
|
||||
langCatalog = mSession->getLanguageCatalog();
|
||||
}
|
||||
auto userState = mSession->loadUser(email, password);
|
||||
UserState user_state;
|
||||
try {
|
||||
user_state = mSession->loadUser(email, password);
|
||||
} catch (Poco::Exception& ex) {
|
||||
addError(new ParamError("login", "exception by calling loadUser: ", ex.displayText()));
|
||||
sendErrorsAsEmail();
|
||||
addError(new Error("Error", "Intern Server error, please try again later"));
|
||||
}
|
||||
auto user = mSession->getNewUser();
|
||||
|
||||
if(userState >= USER_LOADED_FROM_DB && !user->getModel()->getPublicKey()) {
|
||||
if(user_state >= USER_LOADED_FROM_DB && !user->getModel()->getPublicKey()) {
|
||||
if(mSession->generateKeys(true, true)) {
|
||||
userState = USER_COMPLETE;
|
||||
user_state = USER_COMPLETE;
|
||||
if(user->getModel()->isDisabled()) {
|
||||
userState = USER_DISABLED;
|
||||
user_state = USER_DISABLED;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -93,12 +106,17 @@
|
||||
auto uri_start = request.serverParams().getServerName();
|
||||
auto lastExternReferer = mSession->getLastReferer();
|
||||
|
||||
//printf("userState: %d\n", userState);
|
||||
printf("user_state: %d\n", user_state);
|
||||
|
||||
switch(userState) {
|
||||
switch(user_state) {
|
||||
case USER_EMPTY:
|
||||
case USER_PASSWORD_INCORRECT:
|
||||
addError(new Error(langCatalog->gettext("Login"), langCatalog->gettext("E-Mail or password isn't right, please try again!")), false);
|
||||
if(mSession) {
|
||||
getErrors(mSession);
|
||||
sm->releaseSession(mSession);
|
||||
}
|
||||
sm->deleteLoginCookies(request, response);
|
||||
break;
|
||||
case USER_PASSWORD_ENCRYPTION_IN_PROCESS:
|
||||
addError(new Error(langCatalog->gettext("Passwort"), langCatalog->gettext("Passwort wird noch berechnet, bitte versuche es in etwa 1 Minute erneut.")), false);
|
||||
@ -174,7 +192,7 @@
|
||||
<div class="center-form-bottom">
|
||||
<div class="signup-link">
|
||||
<p><%= langCatalog->gettext("You haven't any account yet? Please follow the link to create one.") %></p>
|
||||
<a href="<%= ServerConfig::g_serverPath %>/registerDirect">
|
||||
<a href="https://elopage.com/s/gradido/registration-de/payment?locale=de">
|
||||
<%= langCatalog->gettext("Create New Account") %>
|
||||
</a>
|
||||
</div>
|
||||
@ -183,4 +201,11 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p> </p>
|
||||
<div class="container">
|
||||
<a href="https://docs.google.com/document/d/1jZp-DiiMPI9ZPNXmjsvOQ1BtnfDFfx8BX7CDmA8KKjY/edit?usp=sharing" target="_blank">Zum Whitepaper</a>
|
||||
<br>
|
||||
<br>
|
||||
<a href="https://docs.google.com/document/d/1kcX1guOi6tDgnFHD9tf7fB_MneKTx-0nHJxzdN8ygNs/edit?usp=sharing" target="_blank">To the Whitepaper</a>
|
||||
</div>
|
||||
<%@ include file="footer.cpsp" %>
|
||||
@ -10,6 +10,7 @@
|
||||
#include "../lib/DataTypeConverter.h"
|
||||
|
||||
#include "Poco/Net/HTTPCookie.h"
|
||||
#include "../ServerConfig.h"
|
||||
|
||||
%>
|
||||
<%%
|
||||
@ -53,6 +54,7 @@
|
||||
Die Anmeldung wird verarbeitet und es wird dem Benutzer eine Aktivierungs-E-Mail zugeschickt.
|
||||
</div>
|
||||
</div>
|
||||
<a href="<%= ServerConfig::g_php_serverHost %>">Zurück</a>
|
||||
<% } else { %>
|
||||
<form method="POST">
|
||||
|
||||
|
||||
@ -19,9 +19,9 @@
|
||||
std::string inputPassphrase;
|
||||
|
||||
Mnemonic* wordSource = &ServerConfig::g_Mnemonic_WordLists[ServerConfig::MNEMONIC_BIP0039_SORTED_ORDER];
|
||||
Mnemonic* targetSource = &ServerConfig::g_Mnemonic_WordLists[ServerConfig::MNEMONIC_GRADIDO_BOOK_GERMAN_RANDOM_ORDER];
|
||||
Mnemonic* targetSource = &ServerConfig::g_Mnemonic_WordLists[ServerConfig::MNEMONIC_GRADIDO_BOOK_GERMAN_RANDOM_ORDER_FIXED_CASES];
|
||||
if(lang == LANG_DE) {
|
||||
wordSource = &ServerConfig::g_Mnemonic_WordLists[ServerConfig::MNEMONIC_GRADIDO_BOOK_GERMAN_RANDOM_ORDER];
|
||||
wordSource = &ServerConfig::g_Mnemonic_WordLists[ServerConfig::MNEMONIC_GRADIDO_BOOK_GERMAN_RANDOM_ORDER_FIXED_CASES];
|
||||
targetSource = &ServerConfig::g_Mnemonic_WordLists[ServerConfig::MNEMONIC_BIP0039_SORTED_ORDER];
|
||||
}
|
||||
|
||||
@ -46,7 +46,7 @@
|
||||
), false);
|
||||
} else {
|
||||
if(wordSource == &ServerConfig::g_Mnemonic_WordLists[ServerConfig::MNEMONIC_BIP0039_SORTED_ORDER]) {
|
||||
targetSource = &ServerConfig::g_Mnemonic_WordLists[ServerConfig::MNEMONIC_GRADIDO_BOOK_GERMAN_RANDOM_ORDER];
|
||||
targetSource = &ServerConfig::g_Mnemonic_WordLists[ServerConfig::MNEMONIC_GRADIDO_BOOK_GERMAN_RANDOM_ORDER_FIXED_CASES];
|
||||
} else {
|
||||
targetSource = &ServerConfig::g_Mnemonic_WordLists[ServerConfig::MNEMONIC_BIP0039_SORTED_ORDER];
|
||||
}
|
||||
@ -74,7 +74,7 @@
|
||||
<div class="col-lg-12 col-md-12 mb-5">
|
||||
<form action="<%= uri_start %>/transform_passphrase">
|
||||
<div class="form-group row-showcase_row_area">
|
||||
<textarea name="inputPassphrase" cols="10" rows="5" id="inputPassphrase" class="form-control" placeholder="<%= gettext("deine Passphrase") %>"><%= inputPassphrase %></textarea>
|
||||
<textarea name="inputPassphrase" cols="20" rows="10" id="inputPassphrase" class="form-control" placeholder="<%= gettext("deine Passphrase") %>"><%= inputPassphrase %></textarea>
|
||||
</div>
|
||||
<input name="btnTransform" type="submit" value="Umwandeln" class="btn btn btn-orange">
|
||||
<% if(model::table::ROLE_ADMIN == role) { %>
|
||||
|
||||
@ -1 +1 @@
|
||||
Subproject commit 72e8fe7b73a1aaf2d057d2fef59ade9268830008
|
||||
Subproject commit 81a461566e46d71533dc3e284fa075d7d68fd020
|
||||
@ -5,15 +5,15 @@ fi
|
||||
if [ ! -d "./src/cpp/proto/gradido" ] ; then
|
||||
mkdir ./src/cpp/proto/gradido
|
||||
fi
|
||||
PROTOC_PATH=./dependencies/grpc/_build/third_party/protobuf/Release
|
||||
CPP_PLUGIN_PATH=./dependencies/grpc/_build/Release
|
||||
$PROTOC_PATH/protoc --cpp_out=./src/cpp/proto --proto_path=./src/proto ./src/proto/gradido/*.proto
|
||||
PROTOC_PATH=build/bin
|
||||
CPP_PLUGIN_PATH=build/bin
|
||||
$PROTOC_PATH/protoc.exe --cpp_out=./src/cpp/proto --proto_path=./src/proto ./src/proto/gradido/*.proto
|
||||
|
||||
if [ ! -d "./src/cpp/proto/hedera" ] ; then
|
||||
mkdir ./src/cpp/proto/hedera
|
||||
fi
|
||||
|
||||
GOOGLE_PROTOBUF_INCLUDES=./dependencies/grpc/third_party/protobuf/src
|
||||
$PROTOC_PATH/protoc --plugin=protoc-gen-grpc=$CPP_PLUGIN_PATH/grpc_cpp_plugin.exe --cpp_out=./src/cpp/proto/hedera --grpc_out=./src/cpp/proto/hedera --proto_path=$GOOGLE_PROTOBUF_INCLUDES --proto_path=./src/proto/hedera/hedera-protobuf/src/main/proto ./src/proto/hedera/hedera-protobuf/src/main/proto/*.proto
|
||||
$PROTOC_PATH/protoc.exe --plugin=protoc-gen-grpc=$CPP_PLUGIN_PATH/grpc_cpp_plugin.exe --cpp_out=./src/cpp/proto/hedera --grpc_out=./src/cpp/proto/hedera --proto_path=$GOOGLE_PROTOBUF_INCLUDES --proto_path=./src/proto/hedera/hedera-protobuf/src/main/proto ./src/proto/hedera/hedera-protobuf/src/main/proto/*.proto
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user