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
7f4f7a89
Commit
7f4f7a89
authored
Dec 13, 2015
by
Serge S. Koval
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1139 from pawl/fix_1116
add support for new version of flask-login and flask-security
parents
b36009e6
aef56afc
Changes
14
Show 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 @
7f4f7a89
...
@@ -95,7 +95,7 @@ def init_login():
...
@@ -95,7 +95,7 @@ def init_login():
class
MyModelView
(
sqla
.
ModelView
):
class
MyModelView
(
sqla
.
ModelView
):
def
is_accessible
(
self
):
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
# Create customized index view class that handles login & registration
...
@@ -103,7 +103,7 @@ class MyAdminIndexView(admin.AdminIndexView):
...
@@ -103,7 +103,7 @@ class MyAdminIndexView(admin.AdminIndexView):
@
expose
(
'/'
)
@
expose
(
'/'
)
def
index
(
self
):
def
index
(
self
):
if
not
login
.
current_user
.
is_authenticated
()
:
if
not
login
.
current_user
.
is_authenticated
:
return
redirect
(
url_for
(
'.login_view'
))
return
redirect
(
url_for
(
'.login_view'
))
return
super
(
MyAdminIndexView
,
self
)
.
index
()
return
super
(
MyAdminIndexView
,
self
)
.
index
()
...
@@ -115,7 +115,7 @@ class MyAdminIndexView(admin.AdminIndexView):
...
@@ -115,7 +115,7 @@ class MyAdminIndexView(admin.AdminIndexView):
user
=
form
.
get_user
()
user
=
form
.
get_user
()
login
.
login_user
(
user
)
login
.
login_user
(
user
)
if
login
.
current_user
.
is_authenticated
()
:
if
login
.
current_user
.
is_authenticated
:
return
redirect
(
url_for
(
'.index'
))
return
redirect
(
url_for
(
'.index'
))
link
=
'<p>Don
\'
t have an account? <a href="'
+
url_for
(
'.register_view'
)
+
'">Click here to register.</a></p>'
link
=
'<p>Don
\'
t have an account? <a href="'
+
url_for
(
'.register_view'
)
+
'">Click here to register.</a></p>'
self
.
_template_args
[
'form'
]
=
form
self
.
_template_args
[
'form'
]
=
form
...
...
examples/auth-flask-login/requirements.txt
View file @
7f4f7a89
Flask
Flask
Flask-Admin
Flask-Admin
Flask-SQLAlchemy
Flask-SQLAlchemy
Flask-Login
==0.2.11
Flask-Login
>=0.3.0
examples/auth-flask-login/templates/admin/index.html
View file @
7f4f7a89
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
<div
class=
"row-fluid"
>
<div
class=
"row-fluid"
>
<div>
<div>
{% if current_user.is_authenticated
()
%}
{% if current_user.is_authenticated %}
<h1>
Flask-Admin example
</h1>
<h1>
Flask-Admin example
</h1>
<p
class=
"lead"
>
<p
class=
"lead"
>
Authentication
Authentication
...
...
examples/auth-flask-login/templates/my_master.html
View file @
7f4f7a89
{% extends 'admin/base.html' %}
{% extends 'admin/base.html' %}
{% block access_control %}
{% block access_control %}
{% if current_user.is_authenticated
()
%}
{% if current_user.is_authenticated %}
<div
class=
"btn-group pull-right"
>
<div
class=
"btn-group pull-right"
>
<a
class=
"btn dropdown-toggle"
data-toggle=
"dropdown"
href=
"#"
>
<a
class=
"btn dropdown-toggle"
data-toggle=
"dropdown"
href=
"#"
>
<i
class=
"icon-user"
></i>
{{ current_user.login }}
<span
class=
"caret"
></span>
<i
class=
"icon-user"
></i>
{{ current_user.login }}
<span
class=
"caret"
></span>
...
...
examples/auth-mongoengine/app.py
View file @
7f4f7a89
...
@@ -87,13 +87,13 @@ def init_login():
...
@@ -87,13 +87,13 @@ def init_login():
# Create customized model view class
# Create customized model view class
class
MyModelView
(
ModelView
):
class
MyModelView
(
ModelView
):
def
is_accessible
(
self
):
def
is_accessible
(
self
):
return
login
.
current_user
.
is_authenticated
()
return
login
.
current_user
.
is_authenticated
# Create customized index view class
# Create customized index view class
class
MyAdminIndexView
(
admin
.
AdminIndexView
):
class
MyAdminIndexView
(
admin
.
AdminIndexView
):
def
is_accessible
(
self
):
def
is_accessible
(
self
):
return
login
.
current_user
.
is_authenticated
()
return
login
.
current_user
.
is_authenticated
# Flask views
# Flask views
...
...
examples/auth-mongoengine/requirements.txt
View file @
7f4f7a89
Flask
Flask
Flask-Admin
Flask-Admin
flask-mongoengine
flask-mongoengine
Flask-Login
==0.2.11
Flask-Login
>=0.3.0
examples/auth-mongoengine/templates/index.html
View file @
7f4f7a89
<html>
<html>
<body>
<body>
<div>
<div>
{% if user and user.is_authenticated
()
%}
{% if user and user.is_authenticated %}
Hello {{ user.login }}!
<a
href=
"{{ url_for('logout_view') }}"
>
Logout
</a>
Hello {{ user.login }}!
<a
href=
"{{ url_for('logout_view') }}"
>
Logout
</a>
{% else %}
{% else %}
Welcome anonymous user!
Welcome anonymous user!
...
...
examples/auth/app.py
View file @
7f4f7a89
...
@@ -56,7 +56,7 @@ security = Security(app, user_datastore)
...
@@ -56,7 +56,7 @@ security = Security(app, user_datastore)
class
MyModelView
(
sqla
.
ModelView
):
class
MyModelView
(
sqla
.
ModelView
):
def
is_accessible
(
self
):
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
return
False
if
current_user
.
has_role
(
'superuser'
):
if
current_user
.
has_role
(
'superuser'
):
...
@@ -69,7 +69,7 @@ class MyModelView(sqla.ModelView):
...
@@ -69,7 +69,7 @@ class MyModelView(sqla.ModelView):
Override builtin _handle_view in order to redirect users when a view is not accessible.
Override builtin _handle_view in order to redirect users when a view is not accessible.
"""
"""
if
not
self
.
is_accessible
():
if
not
self
.
is_accessible
():
if
current_user
.
is_authenticated
()
:
if
current_user
.
is_authenticated
:
# permission denied
# permission denied
abort
(
403
)
abort
(
403
)
else
:
else
:
...
...
examples/auth/requirements.txt
View file @
7f4f7a89
Flask
Flask
Flask-Admin
Flask-Admin
Flask-SQLAlchemy
Flask-SQLAlchemy
Flask-Security==1.7.4
Flask-Security>=1.7.5
Flask-Login==0.2.11
examples/auth/templates/admin/index.html
View file @
7f4f7a89
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
<p>
<p>
This example shows how you can use
<a
href=
"https://pythonhosted.org/Flask-Security/index.html"
target=
"_blank"
>
Flask-Security
</a>
for authentication.
This example shows how you can use
<a
href=
"https://pythonhosted.org/Flask-Security/index.html"
target=
"_blank"
>
Flask-Security
</a>
for authentication.
</p>
</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:
<p>
You can register as a regular user, or log in as a superuser with the following credentials:
<ul>
<ul>
<li>
email:
<b>
admin
</b></li>
<li>
email:
<b>
admin
</b></li>
...
...
examples/auth/templates/my_master.html
View file @
7f4f7a89
{% extends 'admin/base.html' %}
{% extends 'admin/base.html' %}
{% block access_control %}
{% block access_control %}
{% if current_user.is_authenticated
()
%}
{% if current_user.is_authenticated %}
<div
class=
"navbar-text btn-group pull-right"
>
<div
class=
"navbar-text btn-group pull-right"
>
<a
href=
"#"
class=
"dropdown-toggle"
data-toggle=
"dropdown"
role=
"button"
aria-expanded=
"false"
>
<a
href=
"#"
class=
"dropdown-toggle"
data-toggle=
"dropdown"
role=
"button"
aria-expanded=
"false"
>
<i
class=
"glyphicon glyphicon-user"
></i>
<i
class=
"glyphicon glyphicon-user"
></i>
...
...
examples/menu-external-links/app.py
View file @
7f4f7a89
...
@@ -19,12 +19,12 @@ class User(UserMixin):
...
@@ -19,12 +19,12 @@ class User(UserMixin):
# Create menu links classes with reloaded accessible
# Create menu links classes with reloaded accessible
class
AuthenticatedMenuLink
(
MenuLink
):
class
AuthenticatedMenuLink
(
MenuLink
):
def
is_accessible
(
self
):
def
is_accessible
(
self
):
return
current_user
.
is_authenticated
()
return
current_user
.
is_authenticated
class
NotAuthenticatedMenuLink
(
MenuLink
):
class
NotAuthenticatedMenuLink
(
MenuLink
):
def
is_accessible
(
self
):
def
is_accessible
(
self
):
return
not
current_user
.
is_authenticated
()
return
not
current_user
.
is_authenticated
# Create custom admin view for authenticated users
# Create custom admin view for authenticated users
...
@@ -34,7 +34,7 @@ class MyAdminView(BaseView):
...
@@ -34,7 +34,7 @@ class MyAdminView(BaseView):
return
self
.
render
(
'authenticated-admin.html'
)
return
self
.
render
(
'authenticated-admin.html'
)
def
is_accessible
(
self
):
def
is_accessible
(
self
):
return
current_user
.
is_authenticated
()
return
current_user
.
is_authenticated
# Create flask app
# Create flask app
...
...
examples/menu-external-links/requirements.txt
View file @
7f4f7a89
Flask
Flask
Flask-Admin
Flask-Admin
Flask-Login
==0.2.11
Flask-Login
>=0.3.0
examples/mongoengine/requirements.txt
View file @
7f4f7a89
Flask
Flask
Flask-Admin
Flask-Admin
Flask-MongoEngine
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