diff --git a/login_server/skeema/gradido_login/groups.sql b/login_server/skeema/gradido_login/groups.sql index 240c56ba5..9d57a3b2c 100644 --- a/login_server/skeema/gradido_login/groups.sql +++ b/login_server/skeema/gradido_login/groups.sql @@ -3,6 +3,7 @@ CREATE TABLE `groups` ( `alias` varchar(190) NOT NULL, `name` varchar(255) NOT NULL, `url` varchar(255) NOT NULL, + `host` varchar(255) DEFAULT "/", `home` varchar(255) DEFAULT "/", `description` text, PRIMARY KEY (`id`), diff --git a/login_server/skeema/gradido_login/insert/setup_docker_group.sql b/login_server/skeema/gradido_login/insert/setup_docker_group.sql index 53a556758..ab600e1af 100644 --- a/login_server/skeema/gradido_login/insert/setup_docker_group.sql +++ b/login_server/skeema/gradido_login/insert/setup_docker_group.sql @@ -1,5 +1,5 @@ -INSERT INTO `groups` (`id`, `alias`, `name`, `url`, `home`, `description`) VALUES -(2, 'docker', 'docker gradido group', 'localhost', '/', 'gradido test group for docker and stage2 with blockchain db'); +INSERT INTO `groups` (`id`, `alias`, `name`, `url`, `host`, `home`, `description`) VALUES +(2, 'docker', 'docker gradido group', 'localhost', 'nginx', '/', 'gradido test group for docker and stage2 with blockchain db'); diff --git a/login_server/src/cpp/controller/Group.cpp b/login_server/src/cpp/controller/Group.cpp index 43285abb3..9217b640a 100644 --- a/login_server/src/cpp/controller/Group.cpp +++ b/login_server/src/cpp/controller/Group.cpp @@ -17,7 +17,7 @@ namespace controller { Poco::AutoPtr Group::create(const std::string& alias, const std::string& name, const std::string& url, const std::string& home, const std::string& description) { - auto db = new model::table::Group(alias, name, url, home, description); + auto db = new model::table::Group(alias, name, url,"", home, description); auto group = new Group(db); return Poco::AutoPtr(group); } @@ -94,7 +94,11 @@ namespace controller { } } auto model = getModel(); - return JsonRequest(model->getUrl(), port); + std::string request_url = model->getHost(); + if ("" == request_url) { + request_url = model->getUrl(); + } + return JsonRequest(request_url, port); } std::string Group::getHost() diff --git a/login_server/src/cpp/model/table/Group.cpp b/login_server/src/cpp/model/table/Group.cpp index 9e4a6af66..3f9cb696c 100644 --- a/login_server/src/cpp/model/table/Group.cpp +++ b/login_server/src/cpp/model/table/Group.cpp @@ -8,15 +8,16 @@ namespace model { { } - Group::Group(const std::string& alias, const std::string& name, const std::string& url, const std::string& home, const std::string& description) - : mAlias(alias), mName(name), mUrl(url), mHome(home), mDescription(description) + Group::Group(const std::string& alias, const std::string& name, const std::string& url, const std::string& host, const std::string& home, const std::string& description) + : mAlias(alias), mName(name), mUrl(url), mHost(host), mHome(home), mDescription(description) { } Group::Group(GroupTuple tuple) : ModelBase(tuple.get<0>()), - mAlias(tuple.get<1>()), mName(tuple.get<2>()), mUrl(tuple.get<3>()), mHome(tuple.get<4>()), mDescription(tuple.get<5>()) + mAlias(tuple.get<1>()), mName(tuple.get<2>()), mUrl(tuple.get<3>()), + mHost(tuple.get<4>()), mHome(tuple.get<5>()), mDescription(tuple.get<6>()) { } @@ -32,6 +33,7 @@ namespace model { ss << "Alias: " << mAlias << std::endl; ss << "Name: " << mName << std::endl; ss << "Url: " << mUrl << std::endl; + ss << "Host: " << mHost << std::endl; ss << "Home: " << mHome << std::endl; ss << "Description:" << mDescription << std::endl; return ss.str(); @@ -41,9 +43,9 @@ namespace model { { Poco::Data::Statement select(session); - select << "SELECT id, alias, name, url, home, description FROM " << getTableName() + select << "SELECT id, alias, name, url, host, home, description FROM " << getTableName() << " where " << fieldName << " = ?" - , into(mID), into(mAlias), into(mName), into(mUrl), into(mHome), into(mDescription); + , into(mID), into(mAlias), into(mName), into(mUrl), into(mHost), into(mHome), into(mDescription); return select; } @@ -52,7 +54,7 @@ namespace model { { Poco::Data::Statement select(session); - select << "SELECT id, alias, name, url, home, description FROM " << getTableName(); + select << "SELECT id, alias, name, url, host, home, description FROM " << getTableName(); return select; } @@ -61,7 +63,7 @@ namespace model { { Poco::Data::Statement select(session); // typedef Poco::Tuple, int> UserTuple; - select << "SELECT id, alias, name, url, home, description FROM " << getTableName() + select << "SELECT id, alias, name, url, host, home, description FROM " << getTableName() << " where " << fieldName << " LIKE ?"; return select; @@ -84,8 +86,8 @@ namespace model { Poco::ScopedLock _lock(mWorkMutex); insert << "INSERT INTO " << getTableName() - << " (alias, name, url, home, description) VALUES(?,?,?,?,?)" - , use(mAlias), use(mName), use(mUrl), use(mHome), use(mDescription); + << " (alias, name, url, host, home, description) VALUES(?,?,?,?,?,?)" + , use(mAlias), use(mName), use(mUrl), use(mHost), use(mHome), use(mDescription); return insert; } diff --git a/login_server/src/cpp/model/table/Group.h b/login_server/src/cpp/model/table/Group.h index 5feb8ba14..8e0c56e40 100644 --- a/login_server/src/cpp/model/table/Group.h +++ b/login_server/src/cpp/model/table/Group.h @@ -7,13 +7,13 @@ namespace model { namespace table { - typedef Poco::Tuple GroupTuple; + typedef Poco::Tuple GroupTuple; class Group : public ModelBase { public: Group(); - Group(const std::string& alias, const std::string& name, const std::string& url, const std::string& home, const std::string& description); + Group(const std::string& alias, const std::string& name, const std::string& url, const std::string& host, const std::string& home, const std::string& description); Group(GroupTuple userTuple); ~Group(); @@ -25,11 +25,13 @@ namespace model { inline const std::string& getName() const { std::shared_lock _lock(mSharedMutex); return mName; } inline const std::string& getDescription() const { std::shared_lock _lock(mSharedMutex); return mDescription; } inline const std::string& getUrl() const { std::shared_lock _lock(mSharedMutex); return mUrl; } + inline const std::string& getHost() const { SHARED_LOCK; return mHost; } inline const std::string& getHome() const { SHARED_LOCK; return mHome; } inline void setName(const std::string& name) { std::unique_lock _lock(mSharedMutex); mName = name; } inline void setDescription(const std::string& desc) { std::unique_lock _lock(mSharedMutex); mDescription = desc; } inline void setUrl(const std::string& url) { std::unique_lock _lock(mSharedMutex); mUrl = url; } + inline void setHost(const std::string& host) { UNIQUE_LOCK; mHost = host; } inline void setHome(const std::string& home) { UNIQUE_LOCK; mHome = home; } protected: @@ -42,6 +44,7 @@ namespace model { std::string mAlias; std::string mName; std::string mUrl; + std::string mHost; std::string mHome; std::string mDescription;