Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
beat.web
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
beat
beat.web
Commits
4ffd465f
Commit
4ffd465f
authored
4 years ago
by
Flavio TARSETTI
Browse files
Options
Downloads
Patches
Plain Diff
[accounts][models] make temporary url hash unique
parent
7fba594c
No related branches found
No related tags found
1 merge request
!328
Improve automatic emails with temporary urls
Pipeline
#39876
passed
4 years ago
Stage: build
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
beat/web/accounts/models.py
+13
-5
13 additions, 5 deletions
beat/web/accounts/models.py
with
13 additions
and
5 deletions
beat/web/accounts/models.py
+
13
−
5
View file @
4ffd465f
...
...
@@ -160,15 +160,23 @@ def save_user_profile(sender, instance, **kwargs):
instance
.
profile
.
save
()
def
generate_url_hash
():
# url_hash creation
url_hash
=
""
.
join
(
random
.
choice
(
string
.
ascii_letters
+
string
.
digits
)
# nosec
for
_
in
range
(
TEMPORARY_URL_LENGTH
)
)
return
url_hash
class
TemporaryUrlManager
(
models
.
Manager
):
def
create_temporary_url
(
self
,
status
,
supervision_track
):
# Actions that result creating the object
#
url_hash
creation
u
rl
_hash
=
""
.
join
(
random
.
choice
(
string
.
ascii_letters
+
string
.
digits
)
# nosec
for
_
in
range
(
TEMPORARY_URL_LENGTH
)
)
url_hash
=
generate_url_hash
()
u
sed
_hash
es
=
[
x
.
url_hash
for
x
in
TemporaryUrl
.
objects
.
all
()]
while
url_hash
in
used_hashes
:
url_hash
=
generate_url_hash
(
)
now
=
datetime
.
datetime
.
now
()
expiration_date_delta
=
datetime
.
timedelta
(
days
=
settings
.
ACCOUNT_ACTIVATION_DAYS_FROM_SUPERVISOR
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment