Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
flask-admin
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Python-Dev
flask-admin
Commits
aef56afc
Commit
aef56afc
authored
Dec 12, 2015
by
Paul Brown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add support for new version of flask-login and flask-security
parent
f2a53614
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
24 additions
and
25 deletions
+24
-25
app.py
examples/auth-flask-login/app.py
+3
-3
requirements.txt
examples/auth-flask-login/requirements.txt
+1
-1
index.html
examples/auth-flask-login/templates/admin/index.html
+2
-2
my_master.html
examples/auth-flask-login/templates/my_master.html
+2
-2
app.py
examples/auth-mongoengine/app.py
+2
-2
requirements.txt
examples/auth-mongoengine/requirements.txt
+1
-1
index.html
examples/auth-mongoengine/templates/index.html
+1
-1
app.py
examples/auth/app.py
+2
-2
requirements.txt
examples/auth/requirements.txt
+1
-2
index.html
examples/auth/templates/admin/index.html
+2
-2
my_master.html
examples/auth/templates/my_master.html
+2
-2
app.py
examples/menu-external-links/app.py
+3
-3
requirements.txt
examples/menu-external-links/requirements.txt
+1
-1
requirements.txt
examples/mongoengine/requirements.txt
+1
-1
No files found.
examples/auth-flask-login/app.py
View file @
aef56afc
...
...
@@ -95,7 +95,7 @@ def init_login():
class
MyModelView
(
sqla
.
ModelView
):
def
is_accessible
(
self
):
return
login
.
current_user
.
is_authenticated
()
return
login
.
current_user
.
is_authenticated
# Create customized index view class that handles login & registration
...
...
@@ -103,7 +103,7 @@ class MyAdminIndexView(admin.AdminIndexView):
@
expose
(
'/'
)
def
index
(
self
):
if
not
login
.
current_user
.
is_authenticated
()
:
if
not
login
.
current_user
.
is_authenticated
:
return
redirect
(
url_for
(
'.login_view'
))
return
super
(
MyAdminIndexView
,
self
)
.
index
()
...
...
@@ -115,7 +115,7 @@ class MyAdminIndexView(admin.AdminIndexView):
user
=
form
.
get_user
()
login
.
login_user
(
user
)
if
login
.
current_user
.
is_authenticated
()
:
if
login
.
current_user
.
is_authenticated
:
return
redirect
(
url_for
(
'.index'
))
link
=
'<p>Don
\'
t have an account? <a href="'
+
url_for
(
'.register_view'
)
+
'">Click here to register.</a></p>'
self
.
_template_args
[
'form'
]
=
form
...
...
examples/auth-flask-login/requirements.txt
View file @
aef56afc
Flask
Flask-Admin
Flask-SQLAlchemy
Flask-Login
==0.2.11
Flask-Login
>=0.3.0
examples/auth-flask-login/templates/admin/index.html
View file @
aef56afc
...
...
@@ -4,7 +4,7 @@
<div
class=
"row-fluid"
>
<div>
{% if current_user.is_authenticated
()
%}
{% if current_user.is_authenticated %}
<h1>
Flask-Admin example
</h1>
<p
class=
"lead"
>
Authentication
...
...
@@ -36,4 +36,4 @@
<a
class=
"btn btn-primary"
href=
"/"
><i
class=
"icon-arrow-left icon-white"
></i>
Back
</a>
</div>
{% endblock body %}
\ No newline at end of file
{% endblock body %}
examples/auth-flask-login/templates/my_master.html
View file @
aef56afc
{% extends 'admin/base.html' %}
{% block access_control %}
{% if current_user.is_authenticated
()
%}
{% if current_user.is_authenticated %}
<div
class=
"btn-group pull-right"
>
<a
class=
"btn dropdown-toggle"
data-toggle=
"dropdown"
href=
"#"
>
<i
class=
"icon-user"
></i>
{{ current_user.login }}
<span
class=
"caret"
></span>
...
...
@@ -11,4 +11,4 @@
</ul>
</div>
{% endif %}
{% endblock %}
\ No newline at end of file
{% endblock %}
examples/auth-mongoengine/app.py
View file @
aef56afc
...
...
@@ -87,13 +87,13 @@ def init_login():
# Create customized model view class
class
MyModelView
(
ModelView
):
def
is_accessible
(
self
):
return
login
.
current_user
.
is_authenticated
()
return
login
.
current_user
.
is_authenticated
# Create customized index view class
class
MyAdminIndexView
(
admin
.
AdminIndexView
):
def
is_accessible
(
self
):
return
login
.
current_user
.
is_authenticated
()
return
login
.
current_user
.
is_authenticated
# Flask views
...
...
examples/auth-mongoengine/requirements.txt
View file @
aef56afc
Flask
Flask-Admin
flask-mongoengine
Flask-Login
==0.2.11
Flask-Login
>=0.3.0
examples/auth-mongoengine/templates/index.html
View file @
aef56afc
<html>
<body>
<div>
{% if user and user.is_authenticated
()
%}
{% if user and user.is_authenticated %}
Hello {{ user.login }}!
<a
href=
"{{ url_for('logout_view') }}"
>
Logout
</a>
{% else %}
Welcome anonymous user!
...
...
examples/auth/app.py
View file @
aef56afc
...
...
@@ -56,7 +56,7 @@ security = Security(app, user_datastore)
class
MyModelView
(
sqla
.
ModelView
):
def
is_accessible
(
self
):
if
not
current_user
.
is_active
()
or
not
current_user
.
is_authenticated
()
:
if
not
current_user
.
is_active
or
not
current_user
.
is_authenticated
:
return
False
if
current_user
.
has_role
(
'superuser'
):
...
...
@@ -69,7 +69,7 @@ class MyModelView(sqla.ModelView):
Override builtin _handle_view in order to redirect users when a view is not accessible.
"""
if
not
self
.
is_accessible
():
if
current_user
.
is_authenticated
()
:
if
current_user
.
is_authenticated
:
# permission denied
abort
(
403
)
else
:
...
...
examples/auth/requirements.txt
View file @
aef56afc
Flask
Flask-Admin
Flask-SQLAlchemy
Flask-Security==1.7.4
Flask-Login==0.2.11
Flask-Security>=1.7.5
examples/auth/templates/admin/index.html
View file @
aef56afc
...
...
@@ -11,7 +11,7 @@
<p>
This example shows how you can use
<a
href=
"https://pythonhosted.org/Flask-Security/index.html"
target=
"_blank"
>
Flask-Security
</a>
for authentication.
</p>
{% if not current_user.is_authenticated
()
%}
{% if not current_user.is_authenticated %}
<p>
You can register as a regular user, or log in as a superuser with the following credentials:
<ul>
<li>
email:
<b>
admin
</b></li>
...
...
@@ -27,4 +27,4 @@
</div>
</div>
</div>
{% endblock body %}
\ No newline at end of file
{% endblock body %}
examples/auth/templates/my_master.html
View file @
aef56afc
{% extends 'admin/base.html' %}
{% block access_control %}
{% if current_user.is_authenticated
()
%}
{% if current_user.is_authenticated %}
<div
class=
"navbar-text btn-group pull-right"
>
<a
href=
"#"
class=
"dropdown-toggle"
data-toggle=
"dropdown"
role=
"button"
aria-expanded=
"false"
>
<i
class=
"glyphicon glyphicon-user"
></i>
...
...
@@ -15,4 +15,4 @@
</ul>
</div>
{% endif %}
{% endblock %}
\ No newline at end of file
{% endblock %}
examples/menu-external-links/app.py
View file @
aef56afc
...
...
@@ -19,12 +19,12 @@ class User(UserMixin):
# Create menu links classes with reloaded accessible
class
AuthenticatedMenuLink
(
MenuLink
):
def
is_accessible
(
self
):
return
current_user
.
is_authenticated
()
return
current_user
.
is_authenticated
class
NotAuthenticatedMenuLink
(
MenuLink
):
def
is_accessible
(
self
):
return
not
current_user
.
is_authenticated
()
return
not
current_user
.
is_authenticated
# Create custom admin view for authenticated users
...
...
@@ -34,7 +34,7 @@ class MyAdminView(BaseView):
return
self
.
render
(
'authenticated-admin.html'
)
def
is_accessible
(
self
):
return
current_user
.
is_authenticated
()
return
current_user
.
is_authenticated
# Create flask app
...
...
examples/menu-external-links/requirements.txt
View file @
aef56afc
Flask
Flask-Admin
Flask-Login
==0.2.11
Flask-Login
>=0.3.0
examples/mongoengine/requirements.txt
View file @
aef56afc
Flask
Flask-Admin
Flask-MongoEngine
Flask-Login
==0.2.11
Flask-Login
>=0.3.0
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment