Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
intranet
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Bertrand Delhomme
intranet
Commits
c8c78e0f
Commit
c8c78e0f
authored
Jul 23, 2012
by
Daniel STAN
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
On enlève la variable POST des rapports, en prod
parent
df317de9
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
2 deletions
+22
-2
templates/login.html
templates/login.html
+1
-1
urls.py
urls.py
+3
-1
utils/__init__.py
utils/__init__.py
+0
-0
utils/protectpost.py
utils/protectpost.py
+18
-0
No files found.
templates/login.html
View file @
c8c78e0f
...
...
@@ -14,7 +14,7 @@
{% if form.errors %}
<div
id=
"message"
>
Your username and password didn't match. Please try again.
</div>
{% endif %}
<form
method=
"post"
action=
"
{% url django.contrib.auth.views.login %}
"
>
{% csrf_token %}
<form
method=
"post"
action=
"
/login
"
>
{% csrf_token %}
{{ form.username.label_tag }}
{{ form.username }}
...
...
urls.py
View file @
c8c78e0f
...
...
@@ -3,6 +3,8 @@
from
django.conf.urls.defaults
import
include
,
patterns
,
url
import
settings
import
django.contrib.auth.views
from
utils.protectpost
import
protect
from
django.contrib
import
admin
admin
.
autodiscover
()
...
...
@@ -12,7 +14,7 @@ urlpatterns = patterns('',
url
(
'^$'
,
'intranet.accueil.view'
),
# Pages de login
url
(
'^login'
,
'django.contrib.auth.views.login'
,
{
'template_name'
:
'login.html'
},
name
=
"login"
),
url
(
'^login'
,
protect
(
django
.
contrib
.
auth
.
views
.
login
)
,
{
'template_name'
:
'login.html'
},
name
=
"login"
),
url
(
'^logout'
,
'django.contrib.auth.views.logout_then_login'
,
name
=
"logout"
),
(
r
'^admin/'
,
include
(
admin
.
site
.
urls
)),
)
...
...
utils/__init__.py
0 → 100644
View file @
c8c78e0f
utils/protectpost.py
0 → 100644
View file @
c8c78e0f
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
import
functools
def
protect
(
f
):
""" Transforme une vue afin d'effacer la variable POST avant rapport
de bug en production.
Cette feature est supportée plus proprement par la dernière version
de django (pas encore dans squeeze) """
@
functools
.
wraps
(
f
)
def
wrapper
(
request
,
*
args
,
**
kwargs
):
try
:
return
f
(
request
,
*
args
,
**
kwargs
)
except
Exception
as
e
:
if
not
settings
.
DEBUG
:
request
.
POST
=
"Censuré (mettre settings.DEBUG=True si voulu)"
raise
e
return
wrapper
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