- changed login server database to community database

- adjusted table names in login server queries
- removed roles model code since its is unused/empty
This commit is contained in:
Ulf Gebhardt 2021-10-21 05:10:45 +02:00
parent c65ac49594
commit 3e726fbe82
No known key found for this signature in database
GPG Key ID: 81308EFE29ABFEBD
12 changed files with 17 additions and 76 deletions

View File

@ -17,7 +17,7 @@ phpServer.host = nginx
loginServer.path = http://localhost/account
loginServer.default_locale = de
loginServer.db.host = mariadb
loginServer.db.name = gradido_login
loginServer.db.name = gradido_community
loginServer.db.user = root
loginServer.db.password =
loginServer.db.port = 3306

View File

@ -19,7 +19,7 @@ namespace model {
// generic db operations
const char* getTableName() const { return "app_access_tokens"; }
const char* getTableName() const { return "login_app_access_tokens"; }
std::string toString();
inline Poco::UInt64 getCode() const { return mAccessCode; }

View File

@ -34,7 +34,7 @@ namespace model {
ElopageBuy();
// generic db operations
const char* getTableName() const { return "elopage_buys"; }
const char* getTableName() const { return "login_elopage_buys"; }
std::string toString();

View File

@ -29,7 +29,7 @@ namespace model {
// generic db operations
const char* getTableName() const { return "email_opt_in"; }
const char* getTableName() const { return "login_email_opt_in"; }
std::string toString();
inline Poco::UInt64 getCode() const { return mEmailVerificationCode; }

View File

@ -17,7 +17,7 @@ namespace model {
Group(GroupTuple userTuple);
// generic db operations
const char* getTableName() const { return "groups"; }
const char* getTableName() const { return "login_groups"; }
std::string toString();
inline const std::string& getAlias() const { return mAlias; }

View File

@ -30,7 +30,7 @@ namespace model {
// generic db operations
const char* getTableName() const { return "pending_tasks"; }
const char* getTableName() const { return "login_pending_tasks"; }
std::string toString();
//! \brief update table row with current request

View File

@ -1,60 +0,0 @@
#ifndef GRADIDO_LOGIN_SERVER_MODEL_TABLE_ROLES_INCLUDE
#define GRADIDO_LOGIN_SERVER_MODEL_TABLE_ROLES_INCLUDE
#include "ModelBase.h"
#include "Poco/Types.h"
#include "Poco/Tuple.h"
namespace model {
namespace table {
enum RoleType {
ROLE_ADMIN = 1
};
class Roles : public ModelBase
{
};
/*
typedef Poco::Tuple<int, int, Poco::UInt64, int> EmailOptInTuple;
class EmailOptIn : public ModelBase
{
public:
EmailOptIn(const Poco::UInt64& code, int user_id, EmailOptInType type);
EmailOptIn(const Poco::UInt64& code, EmailOptInType type);
EmailOptIn(const EmailOptInTuple& tuple);
EmailOptIn();
~EmailOptIn();
// generic db operations
const char* getTableName() { return "email_opt_in"; }
std::string toString();
inline Poco::UInt64 getCode() const { return mEmailVerificationCode; }
inline int getUserId() const { return mUserId; }
inline EmailOptInType getType() const { return static_cast<EmailOptInType>(mType); }
inline void setCode(Poco::UInt64 code) { mEmailVerificationCode = code; }
inline void setUserId(int user_Id) { mUserId = user_Id; }
static const char* typeToString(EmailOptInType type);
protected:
Poco::Data::Statement _loadFromDB(Poco::Data::Session session, const std::string& fieldName);
Poco::Data::Statement _loadIdFromDB(Poco::Data::Session session);
Poco::Data::Statement _loadMultipleFromDB(Poco::Data::Session session, const std::string& fieldName);
Poco::Data::Statement _loadFromDB(Poco::Data::Session session, const std::vector<std::string>& fieldNames, MysqlConditionType conditionType = MYSQL_CONDITION_AND);
Poco::Data::Statement _insertIntoDB(Poco::Data::Session session);
int mUserId;
// data type must be a multiple of 4
Poco::UInt64 mEmailVerificationCode;
int mType;
};
*/
}
}
#endif //GRADIDO_LOGIN_SERVER_MODEL_TABLE_ROLES_INCLUDE

View File

@ -83,11 +83,11 @@ namespace model {
if (mPasswordHashed) {
insert << "INSERT INTO users (email, first_name, last_name, username, description, password, email_hash, language, group_id, publisher_id) VALUES(?,?,?,?,?,?,?,?,?,?);",
insert << "INSERT INTO " << getTableName() << " (email, first_name, last_name, username, description, password, email_hash, language, group_id, publisher_id) VALUES(?,?,?,?,?,?,?,?,?,?);",
use(mEmail), use(mFirstName), use(mLastName), use(mUsername), use(mDescription), bind(mPasswordHashed), use(mEmailHash), use(mLanguageKey), use(mGroupId), use(mPublisherId);
}
else {
insert << "INSERT INTO users (email, first_name, last_name, username, description, email_hash, language, group_id, publisher_id) VALUES(?,?,?,?,?,?,?,?,?);",
insert << "INSERT INTO " << getTableName() << " (email, first_name, last_name, username, description, email_hash, language, group_id, publisher_id) VALUES(?,?,?,?,?,?,?,?,?);",
use(mEmail), use(mFirstName), use(mLastName), use(mUsername), use(mDescription), use(mEmailHash), use(mLanguageKey), use(mGroupId), use(mPublisherId);
}
@ -103,9 +103,11 @@ namespace model {
}
Poco::Data::Statement select(session);
std::string table_name_user_roles = "login_user_roles"
select << "SELECT " << getTableName() << ".id, email, first_name, last_name, username, description, password, pubkey, privkey, email_hash, created, email_checked, language, disabled, group_id, publisher_id, user_roles.role_id "
<< " FROM " << getTableName()
<< " LEFT JOIN user_roles ON " << getTableName() << ".id = user_roles.user_id "
<< " LEFT JOIN " << table_name_user_roles << " ON " << getTableName() << ".id = " << table_name_user_roles << ".user_id "
<< " WHERE " << _fieldName << " = ?" ,
into(mID), into(mEmail), into(mFirstName), into(mLastName), into(mUsername), into(mDescription), into(mPasswordHashed),
into(mPublicKey), into(mPrivateKey), into(mEmailHash), into(mCreated), into(mEmailChecked),
@ -194,7 +196,7 @@ namespace model {
Poco::Data::Statement update(session);
update << "UPDATE users SET password = ?, privkey = ? where id = ?;",
update << "UPDATE " << getTableName() << " SET password = ?, privkey = ? where id = ?;",
bind(mPasswordHashed), use(mPrivateKey), use(mID);
@ -221,7 +223,7 @@ namespace model {
Poco::Data::Statement update(session);
update << "UPDATE users SET pubkey = ?, privkey = ? where id = ?;",
update << "UPDATE " << getTableName() << " SET pubkey = ?, privkey = ? where id = ?;",
use(mPublicKey), use(mPrivateKey), use(mID);
@ -246,7 +248,7 @@ namespace model {
auto session = cm->getConnection(CONNECTION_MYSQL_LOGIN_SERVER);
Poco::Data::Statement update(session);
update << "UPDATE users SET first_name = ?, last_name = ?, username = ?, description = ?, disabled = ?, language = ?, publisher_id = ? where id = ?;",
update << "UPDATE " << getTableName() << " SET first_name = ?, last_name = ?, username = ?, description = ?, disabled = ?, language = ?, publisher_id = ? where id = ?;",
use(mFirstName), use(mLastName), use(mUsername), use(mDescription), use(mDisabled), use(mLanguageKey), use(mPublisherId), use(mID);
try {

View File

@ -54,7 +54,7 @@ namespace model {
// generic db operations
const char* getTableName() const { return "users"; }
const char* getTableName() const { return "login_users"; }
std::string toString();
std::string toHTMLString();

View File

@ -17,7 +17,7 @@ namespace model {
UserBackup();
// generic db operations
const char* getTableName() const { return "user_backups"; }
const char* getTableName() const { return "login_user_backups"; }
std::string toString();
inline int getUserId() const { return mUserId; }

View File

@ -4,7 +4,6 @@
#include "ModelBase.h"
#include "Poco/Types.h"
#include "Poco/Tuple.h"
//#include "Roles.h"
namespace model {
namespace table {
@ -25,7 +24,7 @@ namespace model {
UserRole();
// generic db operations
const char* getTableName() const { return "user_roles"; }
const char* getTableName() const { return "login_user_roles"; }
std::string toString();
inline int getUserId() const { return mUserId; }