Skip to content

Commit

Permalink
Merge pull request #7 from josephmancuso/develop
Browse files Browse the repository at this point in the history
Version 0.2.9
  • Loading branch information
josephmancuso committed Jan 19, 2018
2 parents c6ce90a + 81b07f5 commit 01779a6
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 12 deletions.
9 changes: 5 additions & 4 deletions masonite/facades/Auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 '''
Expand All @@ -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

Expand Down
11 changes: 7 additions & 4 deletions masonite/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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('/')

Expand Down
13 changes: 10 additions & 3 deletions masonite/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 01779a6

Please sign in to comment.