Commit 6d140c9e authored by Leander Schulten's avatar Leander Schulten
Browse files

Fix User Passwort Saving Bugs

parent 7d4473ac
......@@ -85,16 +85,25 @@ bool UserManagment::changeUserPasswort(User *user, const QString &password, cons
return false;
}
User::User(const QJsonObject &o):username(o["username"].toString()),password(o["password"].toString().toUtf8()),permission(static_cast<UserManagment::Permission>(o["permission"].toInt())){
User::User(const QJsonObject &o):username(o["username"].toString()),password(o["password"].toString().toLatin1()),permission(static_cast<UserManagment::Permission>(o["permission"].toInt())){
}
void User::writeJsonObject(QJsonObject &o) const{
o.insert("username",username);
o.insert("password",QString(password));
o.insert("password",QString::fromLatin1(password.constData()));
o.insert("permission",permission);
}
User * UserManagment::getUserByName(const QString &name) const{
for(auto u = user.cbegin();u!=user.cend();++u){
if((**u).getUsername()==name){
return *u;
}
}
return nullptr;
}
......
......@@ -8,6 +8,9 @@
class User;
/**
* @brief The UserManagment class handles user, their permissions and passwords
*/
class UserManagment : public QObject
{
Q_OBJECT
......@@ -20,13 +23,14 @@ public:
UserManagment(const QJsonObject &o);
void load(const QJsonObject &o);
void writeJsonObject(QJsonObject &o)const;
void addUser(User * user);
void addUser(User * user);
Q_INVOKABLE void addUser(const QString & name, const QString & password);
Q_INVOKABLE bool removeUser(User * user,const QString &password);
Q_INVOKABLE bool changeUserName(User * user, const QString &newName,const QString &password);
Q_INVOKABLE bool changeUserPermission(User * user, Permission newPermission,const QString &password);
Q_INVOKABLE bool changeUserPasswort(User * user,const QString &password,const QString &newPassword);
const std::vector<User*>& getUser()const{return user;}
User* getUserByName(const QString & name)const;
};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment