def create(email, username, password): user = User( email=email, username=username, password=password ) user.save() return user
def find_all(): users = User.objects() return list(users)
def change_password(id, password): user = User.objects(id=id).first() if (user_exists(user)): user.password = password user.save() return user;
def delete_by_email(email): user = User.objects(email=email).first() if user_exists(user): user.delete()
def delete_by_username(username): user = User.objects(username=username).first() if user_exists(user): user.delete()
def delete_by_id(identifier): user = User.objects(id=identifier).first() if user_exists(user): user.delete()
def find_by_username(username): user = User.objects(username=username).first() return user_exists(user)
def find_by_email(email): user = User.objects(email=email).first() return user_exists(user)
def find(identifier): user = User.objects(id=identifier).first() return user_exists(user)
def identity(payload): user_id = payload['identity'] return User.objects(id=user_id).first()