[英]devise_token_auth forget password API shows Use POST /sign_in to sign in. GET is not supported error
Following this solution https://stackoverflow.com/a/47761138/7818637 I am designing forgot password flow APIs on rails where I am using devise_token_auth
gem for authentication.遵循此解决方案https://stackoverflow.com/a/47761138/7818637我正在使用
devise_token_auth
gem 进行身份验证的轨道上设计忘记密码流 API。
1. A POST call to send a Password Reset Email 1. POST 调用发送密码重置 Email
URL: http://localhost:3000/client/auth/password
URL:
http://localhost:3000/client/auth/password
form-data: {email: 'john@gmail.com', redirect_url: 'http://localhost:3000/client/auth/sign_in'}
表单数据:
{email: 'john@gmail.com', redirect_url: 'http://localhost:3000/client/auth/sign_in'}
2. A GET call to verify the password reset token (clicked in email) 2. 验证密码重置令牌的 GET 调用(在电子邮件中单击)
I am receiving the the following URL on my console containing redirect_url
and reset_password_token
:我在控制台上收到以下 URL 包含
redirect_url
和reset_password_token
:
http://localhost:3000/client/auth/password/edit?config=default&redirect_url=http%3A%2F%2Flocalhost%3A3000%2Fclient%2Fauth%2Fsign_in&reset_password_token=ZBsx64Gk1VBraM3THZTn
When I call on this URL, I am receiving the following error:当我调用这个 URL 时,我收到以下错误:
Use POST /sign_in to sign in. GET is not supported.
What I have already tried:我已经尝试过的:
Following the issuehere I have found that I am already using include DeviseTokenAuth::Concerns::SetUserByToken
in my controller.在这里的问题之后,我发现我已经在我的 controller 中使用了
include DeviseTokenAuth::Concerns::SetUserByToken
SetUserByToken。
Console Logs:控制台日志:
When the users clicks the url in your email you redirect them to /password/edit path.当用户单击 email 中的 url 时,您会将他们重定向到/password/edit路径。 In this action you verify the user.
在此操作中,您验证用户。 If everything goes right the user will be redirected in redirect_url which is the sign_in path in your case.
如果一切顺利,用户将被重定向到redirect_url ,这是您的情况下的登录路径。
You should change the redirect_url in your email and create an action and a view in which the user will be redirected.您应该更改 email 中的redirect_url并创建将重定向用户的操作和视图。 In this new view you will have the fields so the user can reset the password.
在这个新视图中,您将拥有字段,以便用户可以重置密码。 Make sure that the new url will use 'GET'.
确保新的 url 将使用“GET”。 On form submission redirect user to sign_in path so he/she can log in with their new password.
在提交表单时将用户重定向到登录路径,以便他/她可以使用新密码登录。
Please read https://devise-token-auth.gitbook.io/devise-token-auth/usage/reset_password for more info.请阅读https://devise-token-auth.gitbook.io/devise-token-auth/usage/reset_password了解更多信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.