简体   繁体   English

django-rest-auth重置密码uid和令牌

[英]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.uidthis.props.params.token

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 通过电子邮件的Django-Rest-Auth重置密码 - Django-Rest-Auth Reset Password via email django-rest-auth密码重置在电子邮件中发送错误的域 - django-rest-auth password reset sending wrong domain in email django-rest-auth:密码重置功能问题 - django-rest-auth: Issue with Password Reset functionaliity 令牌密钥名称django-rest-auth - Token key name django-rest-auth Django-rest-auth:如何刷新 Token? - Django-rest-auth : How refresh Token? 如何使用django-rest-auth和Mailgun从Django发送密码重置电子邮件 - How to send password reset email from Django using django-rest-auth and Mailgun django-rest-auth重置密码电子邮件包含&#39;example.com&#39;域而不是site_domain - django-rest-auth reset password email contains 'example.com ' domain instead of site_domain 在django-rest-auth中,密码重置确认URL不起作用-是否缺少参数? - In django-rest-auth, the password reset confirm URL doesn't work--is it missing arguments? Django-rest-auth:未找到“password_reset_confirm”的反转。 “password_reset_confirm”不是有效的视图函数或模式名称 - Django-rest-auth: Reverse for 'password_reset_confirm' not found. 'password_reset_confirm' is not a valid view function or pattern name django-rest-auth通过访问令牌进行的Google社交身份验证 - django-rest-auth google social auth by access token
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM