Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gutyán Gábor
/
circlestack
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
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
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
4 deletions
+19
-4
circle/dashboard/views.py
+19
-4
No files found.
circle/dashboard/views.py
View file @
50327a5d
...
@@ -2173,7 +2173,7 @@ class AbstractVmFunctionView(AccessMixin, View):
...
@@ -2173,7 +2173,7 @@ class AbstractVmFunctionView(AccessMixin, View):
@classmethod
@classmethod
def
get_token
(
cls
,
instance
,
user
,
*
args
):
def
get_token
(
cls
,
instance
,
user
,
*
args
):
t
=
tuple
([
getattr
(
i
,
'pk'
,
i
)
for
i
in
[
instance
,
user
]
+
list
(
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
@classmethod
def
get_token_url
(
cls
,
instance
,
user
,
*
args
):
def
get_token_url
(
cls
,
instance
,
user
,
*
args
):
...
@@ -2623,13 +2623,28 @@ class UnsubscribeFormView(SuccessMessageMixin, UpdateView):
...
@@ -2623,13 +2623,28 @@ class UnsubscribeFormView(SuccessMessageMixin, UpdateView):
@classmethod
@classmethod
def
get_token
(
cls
,
user
):
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
):
def
get_object
(
self
,
queryset
=
None
):
pk
=
signing
.
loads
(
self
.
kwargs
[
'token'
],
salt
=
self
.
get_salt
(),
key
=
self
.
kwargs
[
'token'
]
max_age
=
48
*
3600
)
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
)
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
):
def
set_language_cookie
(
request
,
response
,
lang
=
None
):
if
lang
is
None
:
if
lang
is
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