aboutsummaryrefslogtreecommitdiff
path: root/src/User.cpp
diff options
context:
space:
mode:
authorAleksi Lindeman <0xdec05eba@gmail.com>2018-03-11 00:12:37 +0100
committerAleksi Lindeman <0xdec05eba@gmail.com>2018-03-11 00:13:38 +0100
commit1328d943c5016dd1662a4e46d4a408bca010cffc (patch)
tree8483ee99e3831fca474a2b7b3743e8dbd0e6ee52 /src/User.cpp
parent230e61091b401b8b2bb9496d557a15660fb5072b (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.cpp26
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);
+ }
+ }
+}