Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
50327a5d
authored
Jun 09, 2014
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: improve token handling
parent
0b5dda56
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
5 deletions
+20
-5
circle/dashboard/views.py
+20
-5
No files found.
circle/dashboard/views.py
View file @
50327a5d
...
...
@@ -2173,7 +2173,7 @@ class AbstractVmFunctionView(AccessMixin, View):
@classmethod
def
get_token
(
cls
,
instance
,
user
,
*
args
):
t
=
tuple
([
getattr
(
i
,
'pk'
,
i
)
for
i
in
[
instance
,
user
]
+
list
(
args
)])
return
signing
.
dumps
(
t
,
salt
=
cls
.
get_salt
())
return
signing
.
dumps
(
t
,
salt
=
cls
.
get_salt
()
,
compress
=
True
)
@classmethod
def
get_token_url
(
cls
,
instance
,
user
,
*
args
):
...
...
@@ -2623,12 +2623,27 @@ class UnsubscribeFormView(SuccessMessageMixin, UpdateView):
@classmethod
def
get_token
(
cls
,
user
):
return
signing
.
dumps
(
user
.
pk
,
salt
=
cls
.
get_salt
())
return
signing
.
dumps
(
user
.
pk
,
salt
=
cls
.
get_salt
()
,
compress
=
True
)
def
get_object
(
self
,
queryset
=
None
):
pk
=
signing
.
loads
(
self
.
kwargs
[
'token'
],
salt
=
self
.
get_salt
(),
max_age
=
48
*
3600
)
return
(
queryset
or
self
.
get_queryset
())
.
get
(
user_id
=
pk
)
key
=
self
.
kwargs
[
'token'
]
try
:
pk
=
signing
.
loads
(
key
,
salt
=
self
.
get_salt
(),
max_age
=
48
*
3600
)
except
signing
.
SignatureExpired
:
raise
except
(
signing
.
BadSignature
,
ValueError
,
TypeError
)
as
e
:
logger
.
warning
(
'Tried invalid token. Token:
%
s, user:
%
s.
%
s'
,
key
,
unicode
(
self
.
request
.
user
),
unicode
(
e
))
raise
Http404
else
:
return
(
queryset
or
self
.
get_queryset
())
.
get
(
user_id
=
pk
)
def
dispatch
(
self
,
request
,
*
args
,
**
kwargs
):
try
:
return
super
(
UnsubscribeFormView
,
self
)
.
dispatch
(
request
,
*
args
,
**
kwargs
)
except
signing
.
SignatureExpired
:
return
redirect
(
'dashboard.views.profile-preferences'
)
def
set_language_cookie
(
request
,
response
,
lang
=
None
):
...
...
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