Add sign in and sign out.
This commit is contained in:
parent
2f98c95d21
commit
539275d04e
2 changed files with 19 additions and 6 deletions
|
@ -1,8 +1,8 @@
|
|||
import logging
|
||||
|
||||
from flask import abort, send_file, redirect, request, url_for
|
||||
from flask.ext.login import login_user, UserMixin
|
||||
from flask.ext.principal import identity_changed, Identity
|
||||
from flask.ext.login import login_user, UserMixin, login_required, logout_user
|
||||
from flask.ext.principal import identity_changed, Identity, AnonymousIdentity
|
||||
|
||||
from data import model
|
||||
from app import app, login_manager
|
||||
|
@ -59,3 +59,13 @@ def signin():
|
|||
@app.route('/signin', methods=['GET'])
|
||||
def render_signin_page():
|
||||
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'))
|
||||
|
|
|
@ -43,22 +43,25 @@
|
|||
</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">
|
||||
<div class="form-group">
|
||||
<input type="text" class="form-control" placeholder="Find Repo">
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<li class="dropdown">
|
||||
<li class="dropdown" ng-switch-when="false">
|
||||
<!--<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>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="#">Settings</a></li>
|
||||
<li><a href="#">Sign out</a></li>
|
||||
<li><a href="/signout">Sign out</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li ng-switch-default>
|
||||
<a href="/signin">Sign in</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div><!-- /.navbar-collapse -->
|
||||
</nav>
|
||||
|
|
Reference in a new issue