diff --git a/masonite/facades/Auth.py b/masonite/facades/Auth.py index 00d067d37..086964f83 100644 --- a/masonite/facades/Auth.py +++ b/masonite/facades/Auth.py @@ -2,6 +2,7 @@ import uuid from config import auth +import bcrypt class Auth(object): ''' This class will be used to authenticate users based on the config/auth.py file ''' @@ -27,15 +28,15 @@ def login(self, name, password): ''' Login the user based on the parameters provided ''' auth_column = auth.AUTH['model'].__auth__ try: - model = auth.AUTH['model'].where(auth_column, name).where('password', password).first() - - if model: + model = auth.AUTH['model'].where(auth_column, name).first() + + if model and bcrypt.checkpw(bytes(password, 'utf-8'), bytes(model.password, 'utf-8')): remember_token = str(uuid.uuid4()) model.remember_token = remember_token model.save() self.request.cookie('token', remember_token) return model - + except Exception as exception: raise exception diff --git a/masonite/request.py b/masonite/request.py index 420c4d156..916a9ec57 100644 --- a/masonite/request.py +++ b/masonite/request.py @@ -14,15 +14,15 @@ class Request(object): as a request paramter ''' def __init__(self, environ): - self.method = environ['REQUEST_METHOD'] - self.path = environ['PATH_INFO'] self.cookies = [] - self.environ = environ - self.params = parse_qs(environ['QUERY_STRING']) self.url_params = None self.redirect_url = False self.redirect_route = False self.user_model = None + self.environ = environ + self.params = parse_qs(environ['QUERY_STRING']) + self.method = environ['REQUEST_METHOD'] + self.path = environ['PATH_INFO'] def input(self, param): ''' Returns either the FORM_PARAMS during a POST request @@ -106,6 +106,9 @@ def compile_route_to_url(self): Converts /url/@id into /url/1. Used for redirection ''' + if 'http' in self.redirect_url: + return self.redirect_url + # Split the url into a list split_url = self.redirect_url.split('/') diff --git a/masonite/routes.py b/masonite/routes.py index 6d39dc89b..e352e9234 100644 --- a/masonite/routes.py +++ b/masonite/routes.py @@ -74,18 +74,25 @@ class BaseHttpRoute(object): request = None named_route = None list_middleware = [] - + def route(self, route, output): ''' Loads the route into the class ''' + # If the output specified is a string controller if isinstance(output, str): mod = output.split('@') + # Gets the controller name from the output parameter + # This is used to add support for additional modules + # like 'LoginController' and 'Auth.LoginController' + get_controller = mod[0].split('.')[-1] + # Import the module - module = importlib.import_module('app.http.controllers.' + mod[0]) + module = importlib.import_module( + 'app.http.controllers.' + get_controller) # Get the controller from the module - controller = getattr(module, mod[0]) + controller = getattr(module, get_controller) # Get the view from the controller view = getattr(controller(), mod[1]) diff --git a/setup.py b/setup.py index d435cec16..ad9bcc35d 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ 'masonite.extensions', 'masonite.facades', ], # this must be the same as the name above - version='0.2.7.1', + version='0.2.9', description='The core for the python framework', author='Joseph Mancuso', author_email='idmann509@gmail.com',