Kaynağa Gözat

Move files around, implement localauth

JoostSijm 4 yıl önce
ebeveyn
işleme
f83b0373e5

+ 2 - 2
rival_regions_wrapper/__init__.py

@@ -6,5 +6,5 @@ This unofficial API wrapper is an implementation
 of some Rival Regions functionalities.
 """
 
-# from .authentication_handler.authentication_handler import AuthenticationHandler
-from .middleware.middleware import LocalAuthentication, RemoteAuthentication
+from .authentication_handler import AuthenticationHandler
+from .middleware import LocalAuthentication, RemoteAuthentication

+ 0 - 0
rival_regions_wrapper/authentication_handler/authentication_handler.py → rival_regions_wrapper/authentication_handler.py


+ 9 - 4
rival_regions_wrapper/middleware/middleware.py → rival_regions_wrapper/middleware.py

@@ -4,7 +4,7 @@ from abc import ABC, abstractmethod
 
 import requests
 
-# from authentication_handler import AuthenticationHandler
+from .authentication_handler import AuthenticationHandler
 
 
 class MiddlewareBase(ABC):
@@ -23,16 +23,21 @@ class LocalAuthentication(MiddlewareBase):
     """Local authentication"""
 
     def __init__(self, username, password, login_method):
-        self.username = username
-        self.password = password
-        self.login_method = login_method
+        self.client = AuthenticationHandler()
+        self.client.set_credentials({
+            'username': username,
+            'password': password,
+            'login_method': login_method
+        })
         super().__init__()
 
     def get(self, path, add_c_var=False):
         """Send get requests"""
+        return self.client.get(path)
 
     def post(self, path, data=None):
         """Send post request"""
+        return self.client.post(path, data=data)
 
 
 class RemoteAuthentication(MiddlewareBase):