Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
疯人忠
Cvat
提交
02a2965e
C
Cvat
项目概览
疯人忠
/
Cvat
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
Cvat
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
02a2965e
编写于
8月 04, 2022
作者:
A
Andrey Zhavoronkov
提交者:
GitHub
8月 04, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixed reset password after switching to dj-rest-auth (#52)
上级
a912a445
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
83 addition
and
1 deletion
+83
-1
CHANGELOG.md
CHANGELOG.md
+1
-0
cvat/apps/iam/forms.py
cvat/apps/iam/forms.py
+48
-0
cvat/apps/iam/serializers.py
cvat/apps/iam/serializers.py
+6
-1
cvat/apps/iam/templates/authentication/password_reset_key_message.html
.../templates/authentication/password_reset_key_message.html
+24
-0
cvat/apps/iam/templates/authentication/password_reset_key_message.txt
...m/templates/authentication/password_reset_key_message.txt
+0
-0
cvat/apps/iam/templates/authentication/password_reset_key_subject.txt
...m/templates/authentication/password_reset_key_subject.txt
+4
-0
未找到文件。
CHANGELOG.md
浏览文件 @
02a2965e
...
...
@@ -46,6 +46,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
-
Generated OpenAPI schema for several endpoints
-
Annotation window might have top offset if try to move a locked object
-
Image search in cloud storage (
<https://github.com/cvat-ai/cvat/pull/8>
)
-
Reset password functionality (
<https://github.com/cvat-ai/cvat/pull/52>
)
### Security
-
TDB
...
...
cvat/apps/iam/forms.py
0 → 100644
浏览文件 @
02a2965e
# Copyright (C) 2022 CVAT.ai Corporation
#
# SPDX-License-Identifier: MIT
from
django.contrib.sites.shortcuts
import
get_current_site
from
django.contrib.auth
import
get_user_model
from
allauth.account.forms
import
default_token_generator
from
allauth.account.utils
import
user_pk_to_url_str
from
allauth.account.adapter
import
get_adapter
from
dj_rest_auth.forms
import
AllAuthPasswordResetForm
UserModel
=
get_user_model
()
class
ResetPasswordFormEx
(
AllAuthPasswordResetForm
):
def
save
(
self
,
request
=
None
,
domain_override
=
None
,
email_template_prefix
=
'authentication/password_reset_key'
,
use_https
=
False
,
token_generator
=
default_token_generator
,
extra_email_context
=
None
,
**
kwargs
):
"""
Generate a one-use only link for resetting password and send it to the
user.
"""
email
=
self
.
cleaned_data
[
"email"
]
if
not
domain_override
:
current_site
=
get_current_site
(
request
)
site_name
=
current_site
.
name
domain
=
current_site
.
domain
else
:
site_name
=
domain
=
domain_override
email_field_name
=
UserModel
.
get_email_field_name
()
for
user
in
self
.
users
:
user_email
=
getattr
(
user
,
email_field_name
)
context
=
{
'email'
:
user_email
,
'domain'
:
domain
,
'site_name'
:
site_name
,
'uid'
:
user_pk_to_url_str
(
user
),
'user'
:
user
,
'token'
:
token_generator
.
make_token
(
user
),
'protocol'
:
'https'
if
use_https
else
'http'
,
**
(
extra_email_context
or
{}),
}
get_adapter
(
request
).
send_mail
(
email_template_prefix
,
email
,
context
)
return
self
.
cleaned_data
[
'email'
]
cvat/apps/iam/serializers.py
浏览文件 @
02a2965e
...
...
@@ -9,6 +9,8 @@ from rest_framework import serializers
from
django.conf
import
settings
from
cvat.apps.iam.forms
import
ResetPasswordFormEx
class
RegisterSerializerEx
(
RegisterSerializer
):
first_name
=
serializers
.
CharField
(
required
=
False
)
last_name
=
serializers
.
CharField
(
required
=
False
)
...
...
@@ -23,6 +25,10 @@ class RegisterSerializerEx(RegisterSerializer):
return
data
class
PasswordResetSerializerEx
(
PasswordResetSerializer
):
@
property
def
password_reset_form_class
(
self
):
return
ResetPasswordFormEx
def
get_email_options
(
self
):
domain
=
None
if
hasattr
(
settings
,
'UI_HOST'
)
and
settings
.
UI_HOST
:
...
...
@@ -30,6 +36,5 @@ class PasswordResetSerializerEx(PasswordResetSerializer):
if
hasattr
(
settings
,
'UI_PORT'
)
and
settings
.
UI_PORT
:
domain
+=
':{}'
.
format
(
settings
.
UI_PORT
)
return
{
'email_template_name'
:
'authentication/password_reset_email.html'
,
'domain_override'
:
domain
}
cvat/apps/iam/templates/authentication/password_reset_key_message.html
0 → 100644
浏览文件 @
02a2965e
{% load i18n %}{% autoescape off %}
{% blocktrans %}
<p>
You're receiving this email because you requested a password reset for your user account at {{ site_name }}.
</p>
{% endblocktrans %}
{% trans "Please go to the following page and choose a new password:" %}
{% block reset_link %}
<p>
<a
href=
"{{ protocol }}://{{ domain }}/auth/password/reset/confirm?uid={{ uid }}&token={{ token }}"
>
{{ protocol }}://{{ domain }}/auth/password/reset/confirm?uid={{ uid }}
&
token={{ token }}
</a>
</p>
{% endblock %}
<p>
{% trans "Your username, in case you've forgotten:" %} {{ user.get_username }}
</p>
{% trans "Thanks for using our site!" %}
<p>
{% blocktrans %}The {{ site_name }} team{% endblocktrans %}
</p>
{% endautoescape %}
cvat/apps/iam/templates/authentication/password_reset_
email.html
→
cvat/apps/iam/templates/authentication/password_reset_
key_message.txt
浏览文件 @
02a2965e
文件已移动
cvat/apps/iam/templates/authentication/password_reset_key_subject.txt
0 → 100644
浏览文件 @
02a2965e
{% load i18n %}
{% autoescape off %}
{% blocktrans %}Password Reset E-mail{% endblocktrans %}
{% endautoescape %}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录