Skip to content

Commit

Permalink
removed user auth stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Roland Work - Laptop committed Nov 30, 2014
1 parent d123b98 commit fb43a48
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 37 deletions.
31 changes: 1 addition & 30 deletions appname/controllers/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from flask import Blueprint, render_template, flash, request, redirect, url_for
from flask.ext.login import login_user, logout_user, login_required


from appname import cache
from appname.forms import LoginForm
Expand All @@ -14,32 +14,3 @@ def home():
return render_template('index.html')


@main.route("/login", methods=["GET", "POST"])
def login():
form = LoginForm()
if form.validate_on_submit():
user = User.query.filter_by(username=form.username.data).first()

if user and user.check_password(form.password.data):
login_user(user)

flash("Logged in successfully.", "success")
return redirect(request.args.get("next") or url_for(".home"))
else:
flash("Login failed.", "danger")

return render_template("login.html", form=form)


@main.route("/logout")
def logout():
logout_user()
flash("You have been logged out.", "success")

return redirect(url_for(".home"))


@main.route("/restricted")
@login_required
def restricted():
return "You can only see this if you are logged in!", 200
7 changes: 0 additions & 7 deletions appname/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,6 @@
<ul class="nav navbar-nav">
<li><a href="{{ url_for('.home') }}">Home</a></li>

{% if not current_user.is_authenticated() %}
<li><a href="{{ url_for('.login') }}">Login</a></li>
{% else %}
<li><a href="{{ url_for('.logout') }}">Logout</a></li>
{% endif %}

<li><a href="{{ url_for('.restricted') }}">Login Restricted Page</a></li>
</ul>
</div><!--/.nav-collapse -->
</div>
Expand Down

0 comments on commit fb43a48

Please sign in to comment.