Skip to content

Commit 7237695

Browse files
Merge pull request #100 from MasoniteFramework/develop
Next Major
2 parents 59848d6 + b082a42 commit 7237695

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+632
-622
lines changed

.env-example

+23-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
APP_NAME=Masonite
1+
APP_NAME=Masonite 2.1
22
APP_ENV=local
33
APP_DEBUG=True
44
KEY=your-secret-key
@@ -14,18 +14,38 @@ MAIL_PASSWORD=
1414
MAILGUN_SECRET=
1515
MAILGUN_DOMAIN=
1616

17+
DB_CONNECTION=mysql
1718
DB_DRIVER=mysql
1819
DB_HOST=127.0.0.1
1920
DB_PORT=3306
2021
DB_DATABASE=masonite
2122
DB_USERNAME=root
2223
DB_PASSWORD=root
24+
DB_LOG=True
2325

24-
STRIPE_PUBLISHABLE=
26+
STRIPE_CLIENT=
2527
STRIPE_SECRET=
2628

2729
STORAGE_DRIVER=disk
2830

2931
S3_CLIENT=
3032
S3_SECRET=
31-
S3_BUCKET=
33+
S3_BUCKET=
34+
35+
RACKSPACE_USERNAME=
36+
RACKSPACE_SECRET=
37+
RACKSPACE_CONTAINER=
38+
RACKSPACE_REGION=
39+
40+
AZURE_NAME=
41+
AZURE_SECRET=
42+
AZURE_CONNECTION=
43+
AZURE_CONTAINER=
44+
45+
QUEUE_DRIVER=async
46+
QUEUE_USERNAME=
47+
QUEUE_VHOST=
48+
QUEUE_PASSWORD=
49+
QUEUE_HOST=
50+
QUEUE_PORT=
51+
QUEUE_CHANNEL=

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@
22
.env
33
*__pycache__
44
venv
5-
.env.*
5+
.env.*
6+
.vscode
7+
.pytest_cache

.travis.yml

+5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ python:
33
- "3.4"
44
- "3.5"
55
- "3.6"
6+
matrix:
7+
include:
8+
- python: 3.7
9+
dist: xenial
10+
sudo: true
611
install:
712
- pip install masonite-cli
813
- craft install

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2017 Joseph Mancuso
3+
Copyright (c) 2017-present Joseph Mancuso
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

readme.md README.md

+41-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
<img src="https://travis-ci.org/MasoniteFramework/masonite.svg?branch=master">
99
<img src="https://img.shields.io/badge/python-3.4+-blue.svg" alt="Python Version"> <img src="http://pepy.tech/badge/masonite?1" alt="License"> <img src="https://img.shields.io/github/license/MasoniteFramework/masonite.svg" alt="License">
1010
<img src="https://coveralls.io/repos/github/MasoniteFramework/core/badge.svg?branch=master#" alt="License">
11-
<a href="https://gitter.im/masonite-framework/Lobby"><img src="https://img.shields.io/badge/gitter-join%20chat%20%E2%86%92-brightgreen.svg" alt="gitter"></a>
1211

1312
</p>
1413

@@ -30,7 +29,14 @@ Masonite works hard to be fast and easy from install to deployment so developers
3029

3130
Masonite strives to have extremely comprehensive documentation. All documentation can be [Found Here](https://masoniteframework.gitbooks.io/docs/content/) and would be wise to go through the tutorials there. If you find any discrepencies or anything that doesn't make sense, be sure to comment directly on the documentation to start a discussion!
3231

33-
Also be sure to join the [Slack channel](https://masoniteframework.gitbooks.io/docs/content/)!
32+
Also be sure to join the [Slack channel](http://slack.masoniteproject.com/)!
33+
34+
35+
## Requirements
36+
37+
- Python 3.4 +
38+
- OpenSSL (latest version)
39+
- Pip
3440

3541
## Linux
3642

@@ -46,6 +52,38 @@ Instead of `python-dev` you may need to specify your Python version
4652
$ sudo apt-get install python3.6-dev libssl-dev
4753
```
4854

55+
## Windows
56+
57+
With windows you will need to have the latest OpenSSL version. Install OpenSSL [32-bit](http://slproweb.com/download/Win32OpenSSL-1_1_0h.exe) or [64-bit](http://slproweb.com/download/Win64OpenSSL-1_1_0h.exe)
58+
59+
## Mac
60+
61+
If you do not have the latest version of OpenSSL you will encounter some installation issues with creating new applications since we need to download a zip of the application via GitHub.
62+
63+
With Mac you can install OpenSSL through `brew`.
64+
65+
```
66+
brew install openssl
67+
```
68+
69+
Python 3.6 does not come preinstalled with certificates so you may need to install certificates with this command:
70+
71+
```
72+
/Applications/Python\ 3.6/Install\ Certificates.command
73+
```
74+
75+
You should now be good to install new Masonite application of Mac :)
76+
77+
### Python 3.7
78+
79+
If you are using [Python 3.7](https://www.python.org/downloads/windows/), add it to your PATH Environment variable.
80+
81+
Open Windows PowerShell and run: `pip install masonite-cli`
82+
83+
Add `C:\Users\%USERNAME%\.AppData\Programs\Python\Python37\Scripts\` to PATH Environment variable.
84+
85+
Note: PATH variables depend on your installation folder
86+
4987
## Installation:
5088

5189
```
@@ -205,7 +243,7 @@ Inside the `HelloWorldController` we can make our `show` method like this:
205243

206244
```python
207245
def show(self):
208-
''' Show Hello World Template '''
246+
""" Show Hello World Template """
209247
return view('helloworld')
210248
```
211249

app/User.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
''' User Model '''
1+
"""User Model."""
2+
23
from config.database import Model
34

5+
46
class User(Model):
5-
''' User Model '''
7+
"""User Model."""
68

79
__fillable__ = ['name', 'email', 'password']
810

+19-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,22 @@
1-
''' Welcome The User To Masonite '''
1+
"""Welcome The User To Masonite."""
2+
3+
from masonite.view import View
4+
from masonite.request import Request
5+
26

37
class WelcomeController:
4-
''' Controller For Welcoming The User '''
8+
"""Controller For Welcoming The User."""
9+
10+
def show(self, view: View, request: Request):
11+
"""Show the welcome page.
12+
13+
Arguments:
14+
view {masonite.view.View} -- The Masonite view class.
15+
Application {config.application} -- The application config module.
516
6-
def show(self, Application):
7-
''' Show Welcome Template '''
8-
return view('welcome', {'app': Application})
17+
Returns:
18+
masonite.view.View -- The Masonite view class.
19+
"""
20+
return view.render('welcome', {
21+
'app': request.app().make('Application')
22+
})
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,24 @@
1-
''' Authentication Middleware '''
1+
"""Authentication Middleware."""
2+
3+
from masonite.request import Request
4+
25

36
class AuthenticationMiddleware:
4-
''' Middleware To Check If The User Is Logged In '''
7+
"""Middleware To Check If The User Is Logged In."""
8+
9+
def __init__(self, request: Request):
10+
"""Inject Any Dependencies From The Service Container.
511
6-
def __init__(self, Request):
7-
''' Inject Any Dependencies From The Service Container '''
8-
self.request = Request
12+
Arguments:
13+
Request {masonite.request.Request} -- The Masonite request object
14+
"""
15+
self.request = request
916

1017
def before(self):
11-
''' Run This Middleware Before The Route Executes '''
18+
"""Run This Middleware Before The Route Executes."""
1219
if not self.request.user():
1320
self.request.redirect_to('login')
1421

1522
def after(self):
16-
''' Run This Middleware After The Route Executes '''
23+
"""Run This Middleware After The Route Executes."""
1724
pass

app/http/middleware/CsrfMiddleware.py

+7-44
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,11 @@
1-
''' CSRF Middleware '''
2-
from masonite.exceptions import InvalidCSRFToken
1+
"""CSRF Middleware."""
32

3+
from masonite.middleware import CsrfMiddleware as Middleware
44

5-
class CsrfMiddleware:
6-
''' Verify CSRF Token Middleware '''
75

8-
exempt = []
9-
10-
def __init__(self, Request, Csrf, ViewClass):
11-
self.request = Request
12-
self.csrf = Csrf
13-
self.view = ViewClass
14-
15-
def before(self):
16-
token = self.__verify_csrf_token()
17-
18-
self.view.share({
19-
'csrf_field': "<input type='hidden' name='__token' value='{0}' />".format(token)
20-
})
21-
22-
def after(self):
23-
pass
6+
class CsrfMiddleware(Middleware):
7+
"""Verify CSRF Token Middleware."""
248

25-
def __in_exempt(self):
26-
"""
27-
Determine if the request has a URI that should pass
28-
through CSRF verification.
29-
"""
30-
31-
if self.request.path in self.exempt:
32-
return True
33-
else:
34-
return False
35-
36-
def __verify_csrf_token(self):
37-
"""
38-
Verify si csrf token in post is valid.
39-
"""
40-
41-
if self.request.is_post() and not self.__in_exempt():
42-
token = self.request.input('__token')
43-
if not self.csrf.verify_csrf_token(token):
44-
raise InvalidCSRFToken("Invalid CSRF token.")
45-
else:
46-
token = self.csrf.generate_csrf_token()
47-
48-
return token
9+
exempt = []
10+
every_request = False
11+
token_length = 30
+23-12
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,33 @@
1-
''' Load User Middleware'''
2-
from masonite.facades.Auth import Auth
1+
"""Load User Middleware."""
2+
3+
from masonite.auth import Auth
4+
from masonite.request import Request
5+
36

47
class LoadUserMiddleware:
5-
''' Middleware class which loads the current user into the request '''
8+
"""Middleware class which loads the current user into the request."""
69

7-
def __init__(self, Request):
8-
''' Inject Any Dependencies From The Service Container '''
9-
self.request = Request
10+
def __init__(self, request: Request):
11+
"""Inject Any Dependencies From The Service Container.
12+
13+
Arguments:
14+
Request {masonite.request.Request} -- The Masonite request object.
15+
"""
16+
self.request = request
1017

1118
def before(self):
12-
''' Run This Middleware Before The Route Executes '''
13-
self.load_user(self.request)
19+
"""Run This Middleware Before The Route Executes."""
20+
self.load_user()
1421
return self.request
1522

1623
def after(self):
17-
''' Run This Middleware After The Route Executes '''
24+
"""Run This Middleware After The Route Executes."""
1825
pass
1926

20-
def load_user(self, request):
21-
''' Load user into the request '''
22-
request.set_user(Auth(request).user())
27+
def load_user(self):
28+
"""Load user into the request.
29+
30+
Arguments:
31+
request {masonite.request.Request} -- The Masonite request object.
32+
"""
33+
self.request.set_user(Auth(self.request).user())
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
"""Verify Email Middleware."""
2+
3+
from masonite.request import Request
4+
5+
6+
class VerifyEmailMiddleware:
7+
"""Middleware To Check If The User Has Verified Their Email."""
8+
9+
def __init__(self, request: Request):
10+
"""Inject Any Dependencies From The Service Container.
11+
12+
Arguments:
13+
Request {masonite.request.Request} -- The Masonite request object
14+
"""
15+
self.request = request
16+
17+
def before(self):
18+
"""Run This Middleware Before The Route Executes."""
19+
user = self.request.user()
20+
21+
if user and user.verified_at is None:
22+
self.request.redirect('/email/verify')
23+
24+
def after(self):
25+
"""Run This Middleware After The Route Executes."""
26+
pass

app/providers/.gitignore

Whitespace-only changes.

app/providers/MiddlewareProvider.py

-15
This file was deleted.

app/providers/UserModelProvider.py

-15
This file was deleted.

0 commit comments

Comments
 (0)