[英]django-rest-auth reset password uid and token
Our team works on project with django-rest-api on backend and react on frontend. 我们的团队在后端使用django-rest-api进行项目,并在前端做出反应。 For authentication we use django-rest-auth, and we have problem with password reset. 对于身份验证,我们使用django-rest-auth,我们遇到密码重置问题。 Here urls: 这里的网址是:
urlpatterns += [
url(r'^accounts/', include('allauth.urls')),
url(r'^admin/', include(admin.site.urls)),
url(r'^api/', include('api.urls')),
url(r'^rest-auth/', include('rest_auth.urls')),
url(r'^rest-auth/registration/', include('rest_auth.registration.urls')),
url(
r'^rest-auth/password/reset/$',
PasswordResetView.as_view(),
name='password_reset',
),
url(r'^rest-auth/password/reset/confirm/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$',
PasswordResetConfirmView.as_view(),
name='password_reset_confirm'),
url(
r'^rest-auth/registration/account-confirm-email/(?P<key>[-:\w]+)/$',
confirm,
name="account_confirm_email"
),
url(r'^', include('core.urls', namespace='core')),
]
When request to password_reset is posted, user receives email with link contains uid and token. 当发布对password_reset的请求时,用户会收到包含uid和token的链接的电子邮件。 Then user fills new_password in react form, and we want post data: 然后用户以反应形式填写new_password,我们想要发布数据:
{
"new_password1": "new_password",
"new_password2": "new_password",
"uid": "",
"token": ""
}
to /rest-auth/password/reset/confirm/. to / rest-auth / password / reset / confirm /。
How we may to obtain this uid and token on frontend for make page with confirm password reset on this url, and then post data for confirm password change? 我们如何在前端获取此uid和令牌以在此URL上确认密码重置make页面,然后发布数据以确认密码更改?
You should configure your react router to get the params from url . 您应该配置您的react路由器以从url获取params 。 For eg, 例如,
<Route path="reset/:uid/:token" component={PasswordResetView}/>
And then in your react view you can get these values like this.props.params.uid
and this.props.params.token
. 然后在您的反应视图中,您可以获得这些值,如this.props.params.uid
和this.props.params.token
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.