def register_user(self, username, password, email, access_key, secret_key):
     if User.query.filter(User.username == username).first() == None:
         user = User(username=username,
                     email=email,
                     access_key=access_key,
                     secret_key=secret_key)
         user.hash_password(password)
         self.db_session.add(user)
         self.db_session.commit()
         return True
     else:
         return False
예제 #2
0
 def post():
     try:
         body = request.get_json()
         user = User(**body)
         user.hash_password()
         user.save()
         id = user.id
         return {'id': str(id)}, 200
     except FieldDoesNotExist:
         raise SchemaValidationError
     except NotUniqueError:
         raise EmailAlreadyExistsError
     except Exception:
         raise InternalServerError