Ejemplo n.º 1
0
 def _perform(self, username, password):
     session = self._app.db.session()
     user = session.query(User).filter_by(username=username).first()
     if user is None:
         new_user = User(username=username)
         new_user.set_password(password)
         session.add(new_user)
         return BusinessResponse.response_ok({})
     else:
         return BusinessResponse.response_invalid_data({'message': 'User with this name already exists'})
Ejemplo n.º 2
0
 def _perform(self, username, password):
     session = self._app.db.session()
     user = session.query(User).filter_by(username=username).first()
     if user is not None and user.check_password(password):
         _id = uuid4().get_hex()
         user_session = Session(sid=_id, user=user, data="{}", expire=None)
         session.add(user_session)
         return BusinessResponse.response_ok({'sid': _id})
     else:
         return BusinessResponse.response_invalid_data({'message': 'invalid username or password'})