Add sign in and sign out.

This commit is contained in:
yackob03 2013-09-26 20:18:36 -04:00
parent 2f98c95d21
commit 539275d04e
2 changed files with 19 additions and 6 deletions

View file

@ -1,8 +1,8 @@
import logging import logging
from flask import abort, send_file, redirect, request, url_for from flask import abort, send_file, redirect, request, url_for
from flask.ext.login import login_user, UserMixin from flask.ext.login import login_user, UserMixin, login_required, logout_user
from flask.ext.principal import identity_changed, Identity from flask.ext.principal import identity_changed, Identity, AnonymousIdentity
from data import model from data import model
from app import app, login_manager from app import app, login_manager
@ -59,3 +59,13 @@ def signin():
@app.route('/signin', methods=['GET']) @app.route('/signin', methods=['GET'])
def render_signin_page(): def render_signin_page():
return send_file('templates/signin.html') return send_file('templates/signin.html')
@app.route("/signout")
@login_required
def logout():
logout_user()
identity_changed.send(app, identity=AnonymousIdentity())
return redirect(url_for('index'))

View file

@ -43,22 +43,25 @@
</ul> </ul>
<ul class="nav navbar-nav navbar-right"> <ul class="nav navbar-nav navbar-right" ng-switch on="user.anonymous">
<form class="navbar-form navbar-left" role="search"> <form class="navbar-form navbar-left" role="search">
<div class="form-group"> <div class="form-group">
<input type="text" class="form-control" placeholder="Find Repo"> <input type="text" class="form-control" placeholder="Find Repo">
</div> </div>
</form> </form>
<li class="dropdown"> <li class="dropdown" ng-switch-when="false">
<!--<button type="button" class="btn btn-default navbar-btn">Sign in</button>--> <!--<button type="button" class="btn btn-default navbar-btn">Sign in</button>-->
<a href="javascript:void(0)" class="dropdown-toggle" data-toggle="dropdown">{{ user.username }} <b class="caret"></b></a> <a href="javascript:void(0)" class="dropdown-toggle" data-toggle="dropdown">{{ user.username }} <b class="caret"></b></a>
<ul class="dropdown-menu"> <ul class="dropdown-menu">
<li><a href="#">Settings</a></li> <li><a href="#">Settings</a></li>
<li><a href="#">Sign out</a></li> <li><a href="/signout">Sign out</a></li>
</ul> </ul>
</li> </li>
<li ng-switch-default>
<a href="/signin">Sign in</a>
</li>
</ul> </ul>
</div><!-- /.navbar-collapse --> </div><!-- /.navbar-collapse -->
</nav> </nav>