def post(self): data = UserRegister.parser.parse_args() if UserModel.find_by_email(data['email']): return printResponse( {"message": "A user with that email already exists"}, 400) data['created_at'] = datetime.now() user = UserModel(**data) user.hash_password() user.save_to_db() return printResponse( { "message": "User created successfully.", "id": user._id }, 201)
def post(self): args = self.reqparse.parse_args() user = UserModel(**args) user.id = create_id() user.hash_password() try: result = send_confirm_mail(user) if not result: return {'message': 'Error please try again'}, 500 user.create_user() return {'message': 'Please check your inbox'} except IntegrityError as e: return {'message': 'Email address already exists'}, 409