def put(cls): parser = reqparse.RequestParser() parser.add_argument('username', type=str, required=True) parser.add_argument('password', type=str, required=True) data = parser.parse_args() UserModel.update_user(data['username'], data['password']) return UserModel.get_user()
def post(cls): parser = reqparse.RequestParser() parser.add_argument('username', type=str, required=True) parser.add_argument('password', type=str, required=True) data = parser.parse_args() user = UserModel.get_user() if user and user['username'] == data['username'] and check_password_hash(user['password'], data['password']): return UserModel.encode_jwt_token(user['username']) else: abort(404, message='username and password combination is incorrect')
def before_request_fn(): env: dict = request.environ if request.method != 'OPTIONS' and not ( env.get('REMOTE_ADDR', '') == "127.0.0.1" and "python-requests" in env.get('HTTP_USER_AGENT', '')): if env.get('REMOTE_ADDR', ''): env['REMOTE_ADDR'] = "127.0.0.1" if env.get('HTTP_USER_AGENT', ''): env['HTTP_USER_AGENT'] = "python-requests" from src.users.model_users import UserModel UserModel.authorize()
def before_request_fn(): env: dict = request.environ if not (env.get('REMOTE_ADDR', '') == "127.0.0.1" and "python-requests" in env.get('HTTP_USER_AGENT', '')): from src.users.model_users import UserModel UserModel.authorize()
def create_default_user(): from src.users.model_users import UserModel UserModel.create_user()
def get(cls): user = UserModel.get_user() if not user: raise NotFoundException('Users not found') return user
def create_internal_token(app_setting: AppSetting): internal_token = UserModel.encode_jwt_token("internal_user").get( "access_token") write_file(app_setting.internal_token_file, internal_token) app_setting.internal_token = f'Internal {internal_token}'