aboutsummaryrefslogtreecommitdiff
path: root/src/lb_app/app_db
diff options
context:
space:
mode:
authorneodarz <neodarz@neodarz.net>2018-08-18 21:49:20 +0200
committerneodarz <neodarz@neodarz.net>2018-08-18 21:49:20 +0200
commit7867863b6cd21a87b97df7cabd6871f6a5204602 (patch)
tree95ca60c5a7a064b2d916120a9c220d0383eb4a07 /src/lb_app/app_db
parente9ad5e5069f65aa25cecf4cef136a3ab728fda59 (diff)
downloadliberationCenter-7867863b6cd21a87b97df7cabd6871f6a5204602.tar.xz
liberationCenter-7867863b6cd21a87b97df7cabd6871f6a5204602.zip
Add ability to remove a user
Diffstat (limited to '')
-rw-r--r--src/lb_app/app_db/user.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/lb_app/app_db/user.py b/src/lb_app/app_db/user.py
index 1af957c..7aeab7c 100644
--- a/src/lb_app/app_db/user.py
+++ b/src/lb_app/app_db/user.py
@@ -25,3 +25,18 @@ class User(object):
mongo.db.users.insert({"username": username})
return None
return error
+
+ def remove(self, username):
+ db = MongoDB(self.app)
+ mongo = db.connection()
+ error = None
+
+ if not username:
+ error = 'Username is required.'
+ elif len(list(mongo.db.users.find({"username": username}))) == 0:
+ error = "User {} not exist. So it's good.".format(username)
+
+ if error is None:
+ mongo.db.users.remove({"username": username})
+ return None
+ return error