-
-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed auth command pointing to wrong snippet location
- Loading branch information
1 parent
acec94c
commit af0b464
Showing
10 changed files
with
201 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
include masonite/snippets/exceptions/css/* | ||
include masonite/snippets/* | ||
include masonite/snippets/* | ||
include masonite/snippets/auth/controllers/* | ||
include masonite/snippets/auth/templates/auth/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
''' A Module Description ''' | ||
from masonite.facades.Auth import Auth | ||
|
||
class HomeController(object): | ||
''' Home Dashboard Controller ''' | ||
|
||
def __init__(self): | ||
pass | ||
|
||
def show(self, Request, Application): | ||
if not Auth(Request).user(): | ||
Request.redirect('/login') | ||
return view('auth/home', {'app': Application, 'Auth': Auth(Request)}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
''' A Module Description ''' | ||
from masonite.facades.Auth import Auth | ||
|
||
class LoginController(object): | ||
''' Login Form Controller ''' | ||
|
||
def __init__(self): | ||
pass | ||
|
||
def show(self, Request, Application): | ||
''' Show the login page ''' | ||
return view('auth/login', {'app': Application, 'Auth': Auth(Request)}) | ||
|
||
def store(self, Request): | ||
if Auth(Request).login(Request.input('username'), Request.input('password')): | ||
Request.redirect('/home') | ||
else: | ||
Request.redirect('/login') | ||
return 'check terminal' | ||
|
||
def logout(self, Request): | ||
Auth(Request).logout() | ||
return Request.redirect('/login') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
''' A Module Description ''' | ||
from masonite.facades.Auth import Auth | ||
from config import auth | ||
import bcrypt | ||
|
||
|
||
class RegisterController(object): | ||
''' Class Docstring Description ''' | ||
|
||
def __init__(self): | ||
pass | ||
|
||
def show(self, Request, Application): | ||
''' Show the registration page ''' | ||
return view('auth/register', {'app': Application, 'Auth': Auth(Request)}) | ||
|
||
def store(self, Request): | ||
''' Register a new user ''' | ||
# register the user | ||
password = bcrypt.hashpw( | ||
bytes(Request.input('password'), 'utf-8'), bcrypt.gensalt() | ||
) | ||
|
||
auth.AUTH['model'].create( | ||
name=Request.input('name'), | ||
password=password, | ||
email=Request.input('email'), | ||
) | ||
|
||
# login the user | ||
# redirect to the homepage | ||
if Auth(Request).login(Request.input(auth.AUTH['model'].__auth__), Request.input('password')): | ||
return Request.redirect('/home') | ||
|
||
return Request.redirect('/register') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | ||
<title>{{ app.name }}</title> | ||
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" | ||
crossorigin="anonymous"> | ||
</head> | ||
|
||
<body> | ||
|
||
<nav class="navbar navbar-default"> | ||
<div class="container-fluid"> | ||
<div class="navbar-header"> | ||
<a class="navbar-brand" href="/home">{{ app.NAME }}</a> | ||
</div> | ||
<ul class="nav navbar-nav navbar-right"> | ||
|
||
{% if Auth.user() %} | ||
<li> | ||
<a href="/logout">Logout</a> | ||
</li> | ||
{% else %} | ||
<li> | ||
<a href="/login">Login</a> | ||
</li> | ||
<li> | ||
<a href="/register">Register</a> | ||
</li> | ||
{% endif %} | ||
</ul> | ||
</div> | ||
</nav> | ||
|
||
|
||
|
||
<div class="row"> | ||
{% block content %}{% endblock %} | ||
</div> | ||
|
||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{% extends 'auth/base.html' %} | ||
|
||
{% block content %} | ||
<div class="row"> | ||
<div class="col-xs-8 col-xs-offset-2"> | ||
<div class="panel panel-default"> | ||
<div class="panel-heading">Dashboard</div> | ||
<div class="panel-body"> | ||
This is a dashboard. Hello {{ Auth.user().name }} | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{% extends 'auth/base.html' %} | ||
|
||
{% block content %} | ||
<div class="row"> | ||
<div class="col-xs-4 col-xs-offset-4"> | ||
<div class="panel panel-default"> | ||
<div class="panel-heading">Login</div> | ||
<div class="panel-body"> | ||
<form action="/login" method="POST"> | ||
{{ csrf_field|safe }} | ||
|
||
<div class="form-group"> | ||
<label for="">Username</label> | ||
<input type="text" name="username" class="form-control"> | ||
</div> | ||
|
||
<div class="form-group"> | ||
<label for="">Password</label> | ||
<input type="password" name="password" class="form-control"> | ||
</div> | ||
|
||
<div class="form-group text-center"> | ||
<button type="submit" class="btn btn-success">Login</button> | ||
</div> | ||
</form> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
{% endblock %} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{% extends 'auth/base.html' %} | ||
|
||
{% block content %} | ||
<div class="col-xs-4 col-xs-offset-4"> | ||
<div class="panel panel-default"> | ||
<div class="panel-heading">Register</div> | ||
<div class="panel-body"> | ||
<form action="/register" method="POST"> | ||
{{ csrf_field|safe }} | ||
|
||
<div class="form-group"> | ||
<label for="">Username</label> | ||
<input type="text" name="name" class="form-control"> | ||
</div> | ||
|
||
<div class="form-group"> | ||
<label for="">Email</label> | ||
<input type="email" name="email" class="form-control"> | ||
</div> | ||
|
||
<div class="form-group"> | ||
<label for="">Password</label> | ||
<input type="password" name="password" class="form-control"> | ||
</div> | ||
|
||
<div class="form-group text-center"> | ||
<button type="submit" class="btn btn-success">Register</button> | ||
</div> | ||
</form> | ||
</div> | ||
</div> | ||
</div> | ||
{% endblock %} |