mirror of
https://github.com/IT4Change/gradido.git
synced 2026-04-06 01:25:28 +00:00
added publisher_id field to user
- it can be retrieved with getUserInfos - it can be changed with updateUserInfos
This commit is contained in:
parent
2ebf1d70a4
commit
5ac4d7661a
@ -167,7 +167,8 @@ with:
|
|||||||
"User.last_name" : "Musterman",
|
"User.last_name" : "Musterman",
|
||||||
"User.disabled": 0,
|
"User.disabled": 0,
|
||||||
"User.language": "de",
|
"User.language": "de",
|
||||||
"User.password": "1234"
|
"User.password": "1234",
|
||||||
|
"User.publisher_id": "1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@ -237,7 +238,8 @@ with:
|
|||||||
"user.last_name",
|
"user.last_name",
|
||||||
"user.disabled",
|
"user.disabled",
|
||||||
"user.email_checked",
|
"user.email_checked",
|
||||||
"user.language"
|
"user.language",
|
||||||
|
"user.publisher_id"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@ -273,6 +275,7 @@ Return only the fields which are defined in request
|
|||||||
is in db only saved in state_users so if we delete this entry, validating all transactions is no longer possible. Disabled User cannot login and cannot receive transactions.
|
is in db only saved in state_users so if we delete this entry, validating all transactions is no longer possible. Disabled User cannot login and cannot receive transactions.
|
||||||
- `email_checked`: If user has clicked on link in verification email (register), can only transfer gradidos if email_checked is 1
|
- `email_checked`: If user has clicked on link in verification email (register), can only transfer gradidos if email_checked is 1
|
||||||
- `language`: Language Key for User, currently 'de' or 'en'
|
- `language`: Language Key for User, currently 'de' or 'en'
|
||||||
|
- `publisher_id`: elopage publisher ip
|
||||||
- `errors`: array of strings if error occure
|
- `errors`: array of strings if error occure
|
||||||
|
|
||||||
## Login by Email Verification Code
|
## Login by Email Verification Code
|
||||||
|
|||||||
@ -14,6 +14,7 @@ CREATE TABLE `users` (
|
|||||||
`language` varchar(4) NOT NULL DEFAULT 'de',
|
`language` varchar(4) NOT NULL DEFAULT 'de',
|
||||||
`disabled` tinyint DEFAULT '0',
|
`disabled` tinyint DEFAULT '0',
|
||||||
`group_id` int unsigned DEFAULT 0,
|
`group_id` int unsigned DEFAULT 0,
|
||||||
|
`publisher_id` int DEFAULT 0,
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
UNIQUE KEY `email` (`email`)
|
UNIQUE KEY `email` (`email`)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||||
|
|||||||
@ -134,6 +134,9 @@ Poco::JSON::Object* JsonGetUserInfos::handle(Poco::Dynamic::Var params)
|
|||||||
else if (parameterString == "user.language") {
|
else if (parameterString == "user.language") {
|
||||||
jsonUser.set("language", user_model->getLanguageKey());
|
jsonUser.set("language", user_model->getLanguageKey());
|
||||||
}
|
}
|
||||||
|
else if (parameterString == "user.publisher_id") {
|
||||||
|
jsonUser.set("publisher_id", user_model->getPublisherId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Poco::Exception& ex) {
|
catch (Poco::Exception& ex) {
|
||||||
jsonErrorsArray.add("ask parameter invalid");
|
jsonErrorsArray.add("ask parameter invalid");
|
||||||
|
|||||||
@ -118,6 +118,17 @@ Poco::JSON::Object* JsonUpdateUserInfos::handle(Poco::Dynamic::Var params)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if ("User.publisher_id" == name) {
|
||||||
|
if (value.isInteger()) {
|
||||||
|
int publisher_id = 0;
|
||||||
|
value.convert(publisher_id);
|
||||||
|
user_model->setPublisherId(publisher_id);
|
||||||
|
extractet_values++;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
jsonErrorsArray.add("User.publisher_id isn't a valid integer");
|
||||||
|
}
|
||||||
|
}
|
||||||
else if ("User.password" == name && value.size() > 0 && (ServerConfig::g_AllowUnsecureFlags & ServerConfig::UNSECURE_PASSWORD_REQUESTS) == ServerConfig::UNSECURE_PASSWORD_REQUESTS) {
|
else if ("User.password" == name && value.size() > 0 && (ServerConfig::g_AllowUnsecureFlags & ServerConfig::UNSECURE_PASSWORD_REQUESTS) == ServerConfig::UNSECURE_PASSWORD_REQUESTS) {
|
||||||
if (!value.isString()) {
|
if (!value.isString()) {
|
||||||
jsonErrorsArray.add("User.password isn't string");
|
jsonErrorsArray.add("User.password isn't string");
|
||||||
|
|||||||
@ -15,12 +15,12 @@ namespace model {
|
|||||||
namespace table {
|
namespace table {
|
||||||
|
|
||||||
User::User()
|
User::User()
|
||||||
: mPasswordHashed(0), mEmailChecked(false), mLanguageKey("de"), mDisabled(false), mRole(ROLE_NOT_LOADED)
|
: mPasswordHashed(0), mEmailChecked(false), mLanguageKey("de"), mDisabled(false), mPublisherId(0), mRole(ROLE_NOT_LOADED)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
User::User(const std::string& email, const std::string& first_name, const std::string& last_name, int group_id, Poco::UInt64 passwordHashed/* = 0*/, std::string languageKey/* = "de"*/)
|
User::User(const std::string& email, const std::string& first_name, const std::string& last_name, int group_id, Poco::UInt64 passwordHashed/* = 0*/, std::string languageKey/* = "de"*/)
|
||||||
: mFirstName(first_name), mLastName(last_name), mPasswordHashed(passwordHashed), mEmailChecked(false), mLanguageKey(languageKey), mDisabled(false), mGroupId(group_id), mRole(ROLE_NOT_LOADED)
|
: mFirstName(first_name), mLastName(last_name), mPasswordHashed(passwordHashed), mEmailChecked(false), mLanguageKey(languageKey), mDisabled(false), mGroupId(group_id), mPublisherId(0), mRole(ROLE_NOT_LOADED)
|
||||||
{
|
{
|
||||||
setEmail(email);
|
setEmail(email);
|
||||||
|
|
||||||
@ -29,8 +29,9 @@ namespace model {
|
|||||||
User::User(UserTuple tuple)
|
User::User(UserTuple tuple)
|
||||||
: ModelBase(tuple.get<0>()),
|
: ModelBase(tuple.get<0>()),
|
||||||
mFirstName(tuple.get<1>()), mLastName(tuple.get<2>()), mEmail(tuple.get<3>()), mUsername(tuple.get<4>()),
|
mFirstName(tuple.get<1>()), mLastName(tuple.get<2>()), mEmail(tuple.get<3>()), mUsername(tuple.get<4>()),
|
||||||
mPublicKey(tuple.get<5>()), mCreated(tuple.get<6>()), mEmailChecked(tuple.get<7>()), mDisabled(tuple.get<8>()), mGroupId(tuple.get<9>()),
|
mPublicKey(tuple.get<5>()), mCreated(tuple.get<6>()), mEmailChecked(tuple.get<7>()), mDisabled(tuple.get<8>()),
|
||||||
mPasswordHashed(0), mLanguageKey("de"), mRole(ROLE_NOT_LOADED)
|
mGroupId(tuple.get<9>()), mPublisherId(tuple.get<10>()),
|
||||||
|
mPasswordHashed(0), mLanguageKey("de"), mRole(ROLE_NOT_LOADED)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -82,12 +83,12 @@ namespace model {
|
|||||||
|
|
||||||
|
|
||||||
if (mPasswordHashed) {
|
if (mPasswordHashed) {
|
||||||
insert << "INSERT INTO users (email, first_name, last_name, username, password, email_hash, language, group_id) VALUES(?,?,?,?,?,?,?,?);",
|
insert << "INSERT INTO users (email, first_name, last_name, username, password, email_hash, language, group_id, publisher_id) VALUES(?,?,?,?,?,?,?,?,?);",
|
||||||
use(mEmail), use(mFirstName), use(mLastName), use(mUsername), bind(mPasswordHashed), use(mEmailHash), use(mLanguageKey), use(mGroupId);
|
use(mEmail), use(mFirstName), use(mLastName), use(mUsername), bind(mPasswordHashed), use(mEmailHash), use(mLanguageKey), use(mGroupId), use(mPublisherId);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
insert << "INSERT INTO users (email, first_name, last_name, username, email_hash, language, group_id) VALUES(?,?,?,?,?,?,?);",
|
insert << "INSERT INTO users (email, first_name, last_name, username, email_hash, language, group_id, publisher_id) VALUES(?,?,?,?,?,?,?,?);",
|
||||||
use(mEmail), use(mFirstName), use(mLastName), use(mUsername), use(mEmailHash), use(mLanguageKey), use(mGroupId);
|
use(mEmail), use(mFirstName), use(mLastName), use(mUsername), use(mEmailHash), use(mLanguageKey), use(mGroupId), use(mPublisherId);
|
||||||
}
|
}
|
||||||
|
|
||||||
return insert;
|
return insert;
|
||||||
@ -100,13 +101,13 @@ namespace model {
|
|||||||
_fieldName = getTableName() + std::string(".id");
|
_fieldName = getTableName() + std::string(".id");
|
||||||
}
|
}
|
||||||
Poco::Data::Statement select(session);
|
Poco::Data::Statement select(session);
|
||||||
select << "SELECT " << getTableName() << ".id, email, first_name, last_name, username, password, pubkey, privkey, email_hash, created, email_checked, language, disabled, group_id, user_roles.role_id "
|
select << "SELECT " << getTableName() << ".id, email, first_name, last_name, username, password, pubkey, privkey, email_hash, created, email_checked, language, disabled, group_id, publisher_id, user_roles.role_id "
|
||||||
<< " FROM " << getTableName()
|
<< " FROM " << getTableName()
|
||||||
<< " LEFT JOIN user_roles ON " << getTableName() << ".id = user_roles.user_id "
|
<< " LEFT JOIN user_roles ON " << getTableName() << ".id = user_roles.user_id "
|
||||||
<< " WHERE " << _fieldName << " = ?" ,
|
<< " WHERE " << _fieldName << " = ?" ,
|
||||||
into(mID), into(mEmail), into(mFirstName), into(mLastName), into(mUsername), into(mPasswordHashed),
|
into(mID), into(mEmail), into(mFirstName), into(mLastName), into(mUsername), into(mPasswordHashed),
|
||||||
into(mPublicKey), into(mPrivateKey), into(mEmailHash), into(mCreated), into(mEmailChecked),
|
into(mPublicKey), into(mPrivateKey), into(mEmailHash), into(mCreated), into(mEmailChecked),
|
||||||
into(mLanguageKey), into(mDisabled), into(mGroupId), into(mRole);
|
into(mLanguageKey), into(mDisabled), into(mGroupId), into(mPublisherId), into(mRole);
|
||||||
|
|
||||||
|
|
||||||
return select;
|
return select;
|
||||||
@ -116,7 +117,7 @@ namespace model {
|
|||||||
{
|
{
|
||||||
Poco::Data::Statement select(session);
|
Poco::Data::Statement select(session);
|
||||||
// typedef Poco::Tuple<std::string, std::string, std::string, Poco::Nullable<Poco::Data::BLOB>, int> UserTuple;
|
// typedef Poco::Tuple<std::string, std::string, std::string, Poco::Nullable<Poco::Data::BLOB>, int> UserTuple;
|
||||||
select << "SELECT id, first_name, last_name, email, username, pubkey, created, email_checked, disabled, group_id FROM " << getTableName()
|
select << "SELECT id, first_name, last_name, email, username, pubkey, created, email_checked, disabled, group_id, publisher_id FROM " << getTableName()
|
||||||
<< " where " << fieldName << " LIKE ?";
|
<< " where " << fieldName << " LIKE ?";
|
||||||
|
|
||||||
|
|
||||||
@ -132,7 +133,7 @@ namespace model {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// typedef Poco::Tuple<std::string, std::string, std::string, Poco::Nullable<Poco::Data::BLOB>, int> UserTuple;
|
// typedef Poco::Tuple<std::string, std::string, std::string, Poco::Nullable<Poco::Data::BLOB>, int> UserTuple;
|
||||||
select << "SELECT id, first_name, last_name, email, username, pubkey, created, email_checked, disabled, group_id FROM " << getTableName()
|
select << "SELECT id, first_name, last_name, email, username, pubkey, created, email_checked, disabled, group_id, publisher_id FROM " << getTableName()
|
||||||
<< " where " << fieldNames[0] << " LIKE ?";
|
<< " where " << fieldNames[0] << " LIKE ?";
|
||||||
if (conditionType == MYSQL_CONDITION_AND) {
|
if (conditionType == MYSQL_CONDITION_AND) {
|
||||||
for (int i = 1; i < fieldNames.size(); i++) {
|
for (int i = 1; i < fieldNames.size(); i++) {
|
||||||
@ -244,8 +245,8 @@ namespace model {
|
|||||||
auto session = cm->getConnection(CONNECTION_MYSQL_LOGIN_SERVER);
|
auto session = cm->getConnection(CONNECTION_MYSQL_LOGIN_SERVER);
|
||||||
|
|
||||||
Poco::Data::Statement update(session);
|
Poco::Data::Statement update(session);
|
||||||
update << "UPDATE users SET first_name = ?, last_name = ?, username = ?, disabled = ?, language = ? where id = ?;",
|
update << "UPDATE users SET first_name = ?, last_name = ?, username = ?, disabled = ?, language = ?, publisher_id = ? where id = ?;",
|
||||||
use(mFirstName), use(mLastName), use(mUsername), use(mDisabled), use(mLanguageKey), use(mID);
|
use(mFirstName), use(mLastName), use(mUsername), use(mDisabled), use(mLanguageKey), use(mPublisherId), use(mID);
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@ -28,7 +28,7 @@ namespace model {
|
|||||||
USER_FIELDS_LANGUAGE
|
USER_FIELDS_LANGUAGE
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef Poco::Tuple<int, std::string, std::string, std::string, std::string, Poco::Nullable<Poco::Data::BLOB>, Poco::DateTime, int, int, int> UserTuple;
|
typedef Poco::Tuple<int, std::string, std::string, std::string, std::string, Poco::Nullable<Poco::Data::BLOB>, Poco::DateTime, int, int, int, int> UserTuple;
|
||||||
|
|
||||||
class User : public ModelBase
|
class User : public ModelBase
|
||||||
{
|
{
|
||||||
@ -60,6 +60,7 @@ namespace model {
|
|||||||
inline std::string getNameWithEmailHtml() const { SHARED_LOCK; return mFirstName + " " + mLastName + " <" + mEmail + ">"; }
|
inline std::string getNameWithEmailHtml() const { SHARED_LOCK; return mFirstName + " " + mLastName + " <" + mEmail + ">"; }
|
||||||
inline const Poco::UInt64 getPasswordHashed() const { SHARED_LOCK; return mPasswordHashed; }
|
inline const Poco::UInt64 getPasswordHashed() const { SHARED_LOCK; return mPasswordHashed; }
|
||||||
inline int getGroupId() const { SHARED_LOCK; return mGroupId; }
|
inline int getGroupId() const { SHARED_LOCK; return mGroupId; }
|
||||||
|
inline int getPublisherId() const { SHARED_LOCK; return mPublisherId; }
|
||||||
inline RoleType getRole() const { SHARED_LOCK; if (mRole.isNull()) return ROLE_NONE; return static_cast<RoleType>(mRole.value()); }
|
inline RoleType getRole() const { SHARED_LOCK; if (mRole.isNull()) return ROLE_NONE; return static_cast<RoleType>(mRole.value()); }
|
||||||
inline const unsigned char* getPublicKey() const { SHARED_LOCK; if (mPublicKey.isNull()) return nullptr; return mPublicKey.value().content().data(); }
|
inline const unsigned char* getPublicKey() const { SHARED_LOCK; if (mPublicKey.isNull()) return nullptr; return mPublicKey.value().content().data(); }
|
||||||
MemoryBin* getPublicKeyCopy() const;
|
MemoryBin* getPublicKeyCopy() const;
|
||||||
@ -89,6 +90,7 @@ namespace model {
|
|||||||
inline void setLanguageKey(const std::string& languageKey) { UNIQUE_LOCK; mLanguageKey = languageKey; }
|
inline void setLanguageKey(const std::string& languageKey) { UNIQUE_LOCK; mLanguageKey = languageKey; }
|
||||||
inline void setDisabled(bool disabled) { UNIQUE_LOCK; mDisabled = disabled; }
|
inline void setDisabled(bool disabled) { UNIQUE_LOCK; mDisabled = disabled; }
|
||||||
inline void setGroupId(int groupId) { UNIQUE_LOCK; mGroupId = groupId; }
|
inline void setGroupId(int groupId) { UNIQUE_LOCK; mGroupId = groupId; }
|
||||||
|
inline void setPublisherId(int publisherId) { UNIQUE_LOCK; mPublisherId = publisherId; }
|
||||||
|
|
||||||
Poco::JSON::Object getJson();
|
Poco::JSON::Object getJson();
|
||||||
|
|
||||||
@ -121,6 +123,7 @@ namespace model {
|
|||||||
bool mDisabled;
|
bool mDisabled;
|
||||||
|
|
||||||
int mGroupId;
|
int mGroupId;
|
||||||
|
int mPublisherId;
|
||||||
|
|
||||||
// from neighbor tables
|
// from neighbor tables
|
||||||
Poco::Nullable<int> mRole;
|
Poco::Nullable<int> mRole;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user