diff options
author | dec05eba <dec05eba@protonmail.com> | 2018-03-11 00:12:37 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-08-18 23:25:46 +0200 |
commit | 6099ec04bd0d98b9e75f5b55b1215c94ccf20202 (patch) | |
tree | 9a551e8e723cde057610d6071587bc76b4a6af19 /src/User.cpp | |
parent | 0e62cb8e5ed06d906ad84321cdda22acfcc952c9 (diff) |
Add operation to allow users to be added to group
WARNING! Lazy implementation everywhere, does not handle out-of-order
packets
Diffstat (limited to 'src/User.cpp')
-rw-r--r-- | src/User.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/User.cpp b/src/User.cpp new file mode 100644 index 0000000..e2017ff --- /dev/null +++ b/src/User.cpp @@ -0,0 +1,26 @@ +#include "../include/User.hpp" +#include "../include/Group.hpp" + +namespace odhtdb +{ + User::User(const std::string &_name, Group *group) : name(_name) + { + if(name.size() > 255) + throw UserNameTooLongException(name); + + if(group) + { + groups.emplace_back(group); + group->addUser(this); + } + } + + void User::addToGroup(Group *group) + { + if(group) + { + groups.emplace_back(group); + group->addUser(this); + } + } +} |