django-rest-auth重置密码uid和令牌 [英] django-rest-auth reset password uid and token

查看:150
本文介绍了django-rest-auth重置密码uid和令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的团队在后端使用django-rest-api进行项目工作,并在前端做出反应。
对于身份验证,我们使用django-rest-auth,但密码重置存在问题。
这里的网址:

Our team works on project with django-rest-api on backend and react on frontend. For authentication we use django-rest-auth, and we have problem with password reset. 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')),
]

何时对password_reset的请求已发布,用户收到带有链接的电子邮件,该链接包含uid和令牌。然后,用户以react形式填写new_password,我们要发布数据:

When request to password_reset is posted, user receives email with link contains uid and token. Then user fills new_password in react form, and we want post data:

{
   "new_password1": "new_password",
   "new_password2": "new_password",
   "uid": "",
   "token": ""
}

到/ rest-auth / password / reset / confirm /。

to /rest-auth/password/reset/confirm/.

我们如何在Make页面的前端获得此uid和令牌,并在此url上重置确认密码,然后发布数据以确认密码更改?

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?

推荐答案

您应该配置您的react路由器以获取来自网址的参数。例如,

You should configure your react router to get the params from url. For eg,

<Route path="reset/:uid/:token" component={PasswordResetView}/>

然后在您的反应视图中,您可以获取这些值,例如 this.props .params.uid this.props.params.token

And then in your react view you can get these values like this.props.params.uid and this.props.params.token.

这篇关于django-rest-auth重置密码uid和令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆